r100067 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100066‎ | r100067 | r100068 >
Date:18:16, 17 October 2011
Author:amire80
Status:deferred (Comments)
Tags:
Comment:
Starting refactoring on the way to fixing bug 4030. No functional changes are supposed to be introduced in this version and according to my tests this version is functionally the same as the previous one. The current changes are mostly trying to make this program run under use strict, use warnings and PerlCritic, and even then is not finished yet.
Modified paths:
  • /trunk/extensions/timeline/EasyTimeline.pl (modified) (history)

Diff [purge]

Index: trunk/extensions/timeline/EasyTimeline.pl
@@ -67,18 +67,113 @@
6868 # vulnerability
6969 #
7070 # 1.13 Jan 2010
71 -# -change svg encoding from iso-8859-1 -> UTF-8
72 -# -allow font to be specified using -f option as opposed to hardcoded FreeSans.
 71+# - change svg encoding from iso-8859-1 -> UTF-8
 72+# - allow font to be specified using -f option as opposed to hardcoded FreeSans.
7373
74 -$version = "1.13";
 74+our $VERSION = "1.13";
7575
7676 use Time::Local;
7777 use Getopt::Std;
7878 use Cwd;
 79+use English '-no_match_vars';
7980
 81+# Global variables.
 82+# Many of these should be refactored.
 83+my @PlotLines;
 84+my $CntErrors = 0;
 85+my @Info;
 86+my @Warnings;
 87+
 88+my $file_in;
 89+my $file_name;
 90+my $file_bitmap;
 91+my $file_vector;
 92+my $file_png;
 93+my $file_htmlmap;
 94+my $file_html;
 95+my $file_errors;
 96+
 97+my %options;
 98+my $listinput;
 99+my $linkmap;
 100+my $makehtml;
 101+my $bypass;
 102+my $showmap;
 103+my $tmpdir;
 104+my $ploticus_command;
 105+my $articlepath;
 106+my $font_file;
 107+
 108+my $true = 1;
 109+my $false = 0;
 110+
 111+my $LinkColor = "brightblue";
 112+my $MapPNG = $false; # switched when link or hint found
 113+my $MapSVG = $false; # switched when link found
 114+my $WarnTextOutsideArea = 0;
 115+my $WarnOnRightAlignedText = 0;
 116+
 117+my $hPerc = &EncodeInput("\%");
 118+my $hAmp = &EncodeInput("\&");
 119+my $hAt = &EncodeInput("\@");
 120+my $hDollar = &EncodeInput("\$");
 121+my $hBrO = &EncodeInput("\(");
 122+my $hBrC = &EncodeInput("\)");
 123+my $hSemi = &EncodeInput("\;");
 124+my $hIs = &EncodeInput("\=");
 125+my $hLt = &EncodeInput("\<");
 126+my $hGt = &EncodeInput("\>");
 127+
 128+my $file;
 129+my $image_file_fmt;
 130+my $env;
 131+my $pathseparator;
 132+
 133+my $LineNo;
 134+my $InputParsed;
 135+my $CommandNext = q();
 136+my $Command;
 137+my $DateFormat;
 138+my $Line;
 139+my $NoData;
 140+
 141+my %Consts; # see sub GetDefine
 142+my %Colors; # see sub StoreColor
 143+my %BackgroundColors;
 144+my %Axis;
 145+my @Bars;
 146+my %BarLegend;
 147+my %BarLink;
 148+my @LegendData;
 149+my %LineDefs;
 150+my $AlignBars;
 151+my %ColorLabels;
 152+my %Period;
 153+my @DrawLines;
 154+my %Image;
 155+my %Legend;
 156+my %PlotArea;
 157+my %PlotDefs;
 158+my @PlotBars;
 159+my @PlotText;
 160+my $MaxBarWidth;
 161+my %BarWidths;
 162+my $maxwidth; # XXX problematic
 163+my $Preset;
 164+my @PresetList;
 165+my %Scales;
 166+my %TextDefs;
 167+
 168+# These two must definitely be refactored
 169+my %Attributes;
 170+my @Attributes;
 171+
 172+my $firstcmd;
 173+
 174+# BEGIN
80175 $| = 1; # flush screen output
81176
82 -print "EasyTimeline version $version\n"
 177+print "EasyTimeline version $VERSION\n"
83178 . "Copyright (C) 2004 Erik Zachte\n"
84179 . "Email xxx\@chello.nl (nospam: xxx=epzachte)\n\n"
85180 . "This program is free software; you can redistribute it\n"
@@ -92,23 +187,29 @@
93188 &InitFiles;
94189
95190 open "FILE_IN", "<", $file_in;
96 -@lines = <FILE_IN>;
 191+my @lines = <FILE_IN>;
97192 close "FILE_IN";
98193
99 -&InitVars;
100194 &ParseScript;
101195
102 -if ($CntErrors == 0) { &WritePlotFile; }
 196+if ($CntErrors == 0) {
 197+ &WritePlotFile;
 198+}
103199
104 -if ($CntErrors == 1) { &Abort("1 error found"); }
105 -elsif ($CntErrors > 1) { &Abort("$CntErrors errors found"); }
 200+if ($CntErrors == 1) {
 201+ &Abort("1 error found");
 202+}
 203+elsif ($CntErrors > 1) {
 204+ &Abort("$CntErrors errors found");
 205+}
106206 else {
107 - if (defined @Info) {
 207+ if (@Info) {
108208 print "\nINFO\n";
109209 print @Info;
110210 print "\n";
111211 }
112 - if (defined @Warnings) {
 212+
 213+ if (@Warnings) {
113214 print "\nWARNING(S)\n";
114215 print @Warnings;
115216 print "\n";
@@ -133,55 +234,50 @@
134235 my $options;
135236 getopt("iTAPef", \%options);
136237
137 - &Abort("Specify input file as: -i filename") if (!defined(@options{"i"}));
 238+ &Abort("Specify input file as: -i filename") if (!defined($options{"i"}));
138239
139 - $file_in = @options{"i"};
140 - $listinput = @options{"l"}; # list all input lines (not recommended)
141 - $linkmap = @options{"m"}; # make clickmap for inclusion in html
142 - $makehtml = @options{"h"}; # make test html file with gif/png + svg output
143 - $bypass = @options{"b"}; # do not use in Wikipedia:bypass some checks
144 - $showmap = @options{"d"}; # debug: shows clickable areas in gif/png
145 - # The following parameters are used by MediaWiki
146 - # to pass config settings from LocalSettings.php to
147 - # the perl script
148 - $tmpdir = @options{"T"}; # For MediaWiki: temp directory to use
149 - $plcommand = @options{"P"}; # For MediaWiki: full path of ploticus command
150 - $articlepath = @options{"A"
151 - }; # For MediaWiki: Path of an article, relative to this servers root
152 - $font_file = @options{"f"
153 - }; # font to use. Must be in environemnt variable GDFONTPATH unless builtin "ascii" font
 240+ $file_in = $options{"i"};
 241+ $listinput = $options{"l"}; # list all input lines (not recommended)
 242+ $linkmap = $options{"m"}; # make clickmap for inclusion in html
 243+ # make test html file with gif/png + svg output
 244+ $makehtml = $options{"h"};
154245
155 - if (!defined @options{"f"}) { $font_file = "ascii"; }
 246+ # do not use in Wikipedia:bypass some checks
 247+ $bypass = $options{"b"};
156248
157 - if (!defined @options{"A"}) {
 249+ # debug: shows clickable areas in gif/png
 250+ $showmap = $options{"d"};
 251+
 252+ # The following parameters are used by MediaWiki
 253+ # to pass config settings from LocalSettings.php to
 254+ # the perl script
 255+
 256+ # For MediaWiki: temp directory to use
 257+ $tmpdir = $options{"T"};
 258+
 259+ # For MediaWiki: full path of ploticus command
 260+ $ploticus_command = $options{"P"};
 261+
 262+ # For MediaWiki: Path of an article, relative to this servers root
 263+ $articlepath = $options{"A"};
 264+
 265+ # font to use. Must be in environemnt variable
 266+ # GDFONTPATH unless builtin "ascii" font
 267+ $font_file = $options{"f"};
 268+
 269+ if (!defined $options{"f"}) {
 270+ $font_file = "ascii";
 271+ }
 272+
 273+ if (!defined $options{"A"}) {
158274 $articlepath = "http://en.wikipedia.org/wiki/\$1";
159275 }
160276
161 - if (!-e $file_in) { &Abort("Input file '" . $file_in . "' not found."); }
 277+ if (!-e $file_in) {
 278+ &Abort("Input file '" . $file_in . "' not found.");
 279+ }
162280 }
163281
164 -sub InitVars {
165 - $true = 1;
166 - $false = 0;
167 - $CntErrors = 0;
168 - $LinkColor = "brightblue";
169 - $MapPNG = $false; # switched when link or hint found
170 - $MapSVG = $false; # switched when link found
171 - $WarnTextOutsideArea = 0;
172 - $WarnOnRightAlignedText = 0;
173 -
174 - $hPerc = &EncodeInput("\%");
175 - $hAmp = &EncodeInput("\&");
176 - $hAt = &EncodeInput("\@");
177 - $hDollar = &EncodeInput("\$");
178 - $hBrO = &EncodeInput("\(");
179 - $hBrC = &EncodeInput("\)");
180 - $hSemi = &EncodeInput("\;");
181 - $hIs = &EncodeInput("\=");
182 - $hLt = &EncodeInput("\<");
183 - $hGt = &EncodeInput("\>");
184 -}
185 -
186282 sub InitFiles {
187283 print "\nInput: Script file $file_in\n";
188284
@@ -190,7 +286,7 @@
191287 # 1.10 dot ignore dots in folder names ->
192288 $file =~ s/\.[^\\\/\.]*$//; # remove extension
193289 $file_name = $file;
194 - $file_bitmap = $file . "." . $fmt;
 290+ $file_bitmap = $file . "." . $image_file_fmt;
195291 $file_vector = $file . ".svg";
196292 $file_png = $file . ".png";
197293 $file_htmlmap = $file . ".map";
@@ -220,28 +316,28 @@
221317 $env = "";
222318
223319 # $dir = cwd() ; # is there a better way to detect OS?
224 - # if ($dir =~ /\//) { $env = "Linux" ; $fmt = "png" ; $pathseparator = "/";}
225 - # if ($dir =~ /\\/) { $env = "Windows" ; $fmt = "gif" ; $pathseparator = "\\";}
 320+ # if ($dir =~ /\//) { $env = "Linux" ; $image_file_fmt = "png" ; $pathseparator = "/";}
 321+ # if ($dir =~ /\\/) { $env = "Windows" ; $image_file_fmt = "gif" ; $pathseparator = "\\";}
226322 # cwd always to returns '/'s ? ->
227 - $OS = $^O;
228 - if ($OS =~ /darwin/i) {
229 - $env = "Linux";
230 - $fmt = "png";
231 - $pathseparator = "/";
 323+ if ($OSNAME =~ /darwin/i) {
 324+ $env = "Linux";
 325+ $image_file_fmt = "png";
 326+ $pathseparator = "/";
232327 }
233 - elsif ($OS =~ /win/i) {
234 - $env = "Windows";
235 - $fmt = "gif";
236 - $pathseparator = "\\";
 328+ elsif ($OSNAME =~ /win/i) {
 329+ $env = "Windows";
 330+ $image_file_fmt = "gif";
 331+ $pathseparator = "\\";
237332 }
238 - else { $env = "Linux"; $fmt = "png"; $pathseparator = "/"; }
 333+ else { $env = "Linux"; $image_file_fmt = "png"; $pathseparator = "/"; }
239334
240335 if ($env ne "") {
241 - print "\nOS $env detected -> create image in $fmt format.\n";
 336+ print
 337+ "\nOS $env detected -> create image in $image_file_fmt format.\n";
242338 }
243339 else {
244340 print
245 - "\nOS not detected. Assuming Windows -> create image in $fmt format.\n";
 341+ "\nOS not detected. Assuming Windows -> create image in $image_file_fmt format.\n";
246342 $env = "Windows";
247343 }
248344 }
@@ -337,7 +433,7 @@
338434 )
339435 {
340436 my @attributes = split(" ", $value);
341 - foreach $attribute (@attributes) {
 437+ foreach my $attribute (@attributes) {
342438 my ($attrname, $attrvalue) = split("\:", $attribute);
343439 if (
344440 !(
@@ -395,24 +491,31 @@
396492 }
397493
398494 sub GetLine {
399 - if ($#lines < 0) { $InputParsed = $true; return (""); }
 495+ if ($#lines < 0) {
 496+ $InputParsed = $true;
 497+ return ("");
 498+ }
400499
401500 # running in Wikipedia context and first line empty ?
402501 # skip first line without incrementing line count
403502 # this is part behind <timeline> and will not be thought of as line 1
404 - if (defined @options{"A"}) {
405 - if (($#lines >= 0) && (@lines[0] =~ /^\s*$/)) {
 503+ if (defined $options{"A"}) {
 504+ if (($#lines >= 0) && ($lines[0] =~ /^\s*$/)) {
406505 $Line = shift(@lines);
407506 }
408507 }
409508
 509+ my $commentstart;
 510+
410511 $Line = "";
411512 while (($#lines >= 0) && ($Line =~ /^\s*$/)) {
412513 $LineNo++;
413514 $Line = shift(@lines);
414515 chomp($Line);
415516
416 - if ($listinput) { print "$LineNo: " . &DecodeInput($Line) . "\n"; }
 517+ if ($listinput) {
 518+ print "$LineNo: " . &DecodeInput($Line) . "\n";
 519+ }
417520
418521 # preserve '#' within double quotes
419522 $Line =~ s/(\"[^\"]*\")/$a=$1,$a=~s^\#^\%\?\+^g,$a/ge;
@@ -473,7 +576,7 @@
474577 }
475578
476579 if ($Command =~ /^[^\s]/) {
477 - $line = $Command;
 580+ my $line = $Command;
478581 $line =~ s/^.*$hIs\s*//;
479582 &CollectAttributes($line);
480583 }
@@ -503,12 +606,10 @@
504607 sub CollectAttributes {
505608 my $line = shift;
506609
507 - $line =~ s/(\slink\:[^\s\:]*)\:/$1'colon'/i
508 - ; # replace colon (:), would conflict with syntax
509 - $line =~ s/(\stext\:[^\s\:]*)\:/$1'colon'/i
510 - ; # replace colon (:), would conflict with syntax
511 - $line =~ s/(https?)\:/$1'colon'/i
512 - ; # replace colon (:), would conflict with syntax
 610+ # replace colon (:), would conflict with syntax
 611+ $line =~ s/(\slink\:[^\s\:]*)\:/$1'colon'/i;
 612+ $line =~ s/(\stext\:[^\s\:]*)\:/$1'colon'/i;
 613+ $line =~ s/(https?)\:/$1'colon'/i;
513614
514615 my $text;
515616 ($line, $text) = &ExtractText($line);
@@ -517,10 +618,10 @@
518619 $line =~ s/( $hBrO .+? $hBrC )/&RemoveSpaces($1)/gxe;
519620 $line =~ s/\s*\:\s*/:/g;
520621 $line =~ s/([a-zA-Z0-9\_]+)\:/lc($1) . ":"/gxe;
521 - @Fields = split(" ", $line);
 622+ my @Fields = split(" ", $line);
522623
523 - $name = "";
524 - foreach $field (@Fields) {
 624+ my ($name, $value);
 625+ foreach my $field (@Fields) {
525626 if ($field =~ /\:/) {
526627 ($name, $value) = split(":", $field);
527628 $name =~ s/^\s*(.*)\s*$/lc($1)/gxe;
@@ -546,29 +647,29 @@
547648 );
548649 }
549650 }
550 - else { @Attributes{$name} = $value; }
 651+ else { $Attributes{$name} = $value; }
551652 }
552653 else {
553 - if (defined(@Attributes{"single"})) {
 654+ if (defined($Attributes{"single"})) {
554655 &Error(
555656 "Invalid attribute '$field' ignored.\nSpecify attributes as 'name:value' pair(s)."
556657 );
557658 }
558659 else {
559660 $field =~ s/^\s*(.*)\s*$/$1/gxe;
560 - @Attributes{"single"} = $field;
 661+ $Attributes{"single"} = $field;
561662 }
562663 }
563664 }
564 - if (($name ne "") && (@Attributes{"single"} ne "")) {
 665+ if (($name ne "") && ($Attributes{"single"} ne "")) {
565666 &Error( "Invalid attribute '"
566 - . @Attributes{"single"}
 667+ . $Attributes{"single"}
567668 . "' ignored.\nSpecify attributes as 'name:value' pairs.");
568 - delete(@Attributes{"single"});
 669+ delete($Attributes{"single"});
569670 }
570671
571672 if ((defined($text)) && ($text ne "")) {
572 - @Attributes{"text"} = &ParseText($text);
 673+ $Attributes{"text"} = &ParseText($text);
573674 }
574675 }
575676
@@ -576,7 +677,7 @@
577678 my $command = shift;
578679 my $const = shift;
579680 $const = lc($const);
580 - my $value = @Consts{ lc($const) };
 681+ my $value = $Consts{ lc($const) };
581682 if (!defined($value)) {
582683 &Error("Unknown constant. 'Define $const = ... ' expected.");
583684 return ($const);
@@ -587,7 +688,7 @@
588689 sub ParseAlignBars {
589690 &CheckPreset("AlignBars");
590691
591 - $align = @Attributes{"single"};
 692+ my $align = $Attributes{"single"};
592693 if (!($align =~ /^(?:justify|early|late)$/i)) {
593694 &Error(
594695 "AlignBars value '$align' invalid. Specify 'justify', 'early' or 'late'."
@@ -599,16 +700,19 @@
600701 }
601702
602703 sub ParseBackgroundColors {
603 - if (!&ValidAttributes("BackgroundColors")) { &GetData; next; }
 704+ if (!&ValidAttributes("BackgroundColors")) {
 705+ &GetData;
 706+ next;
 707+ }
604708
605709 &CheckPreset("BackGroundColors");
606710
607 - foreach $attribute (keys %Attributes) {
608 - my $attrvalue = @Attributes{$attribute};
 711+ foreach my $attribute (keys %Attributes) {
 712+ my $attrvalue = $Attributes{$attribute};
609713
610714 if ($attribute =~ /Canvas/i) {
611715 if (!&ColorPredefined($attrvalue)) {
612 - if (!defined(@Colors{ lc($attrvalue) })) {
 716+ if (!defined($Colors{ lc($attrvalue) })) {
613717 &Error(
614718 "BackgroundColors definition invalid. Attribute '$attribute': unknown color '$attrvalue'.\n"
615719 . " Specify command 'Color' before this command."
@@ -616,20 +720,22 @@
617721 return;
618722 }
619723 }
620 - if (defined(@Colors{ lc($attrvalue) })) {
621 - @Attributes{"canvas"} = @Colors{ lc($attrvalue) };
 724+ if (defined($Colors{ lc($attrvalue) })) {
 725+ $Attributes{"canvas"} = $Colors{ lc($attrvalue) };
622726 }
623 - else { @Attributes{"canvas"} = lc($attrvalue); }
 727+ else {
 728+ $Attributes{"canvas"} = lc($attrvalue);
 729+ }
624730 }
625731 elsif ($attribute =~ /Bars/i) {
626 - if (!defined(@Colors{ lc($attrvalue) })) {
 732+ if (!defined($Colors{ lc($attrvalue) })) {
627733 &Error(
628734 "BackgroundColors definition invalid. Attribute '$attribute' unknown color '$attrvalue'.\n"
629735 . " Specify command 'Color' before this command.");
630736 return;
631737 }
632738
633 - @Attributes{"bars"} = lc($attrvalue);
 739+ $Attributes{"bars"} = lc($attrvalue);
634740 }
635741 }
636742
@@ -656,12 +762,13 @@
657763 $hint = "";
658764 $barset = ""; # $barcount = "" ;
659765
660 - my $data2 = $data;
 766+ # warn "data: $data";
 767+ my $data2; # = $data;
661768 ($data2, $text) = &ExtractText($data2);
662769 @Attributes = split(" ", $data2);
663770
664 - foreach $attribute (keys %Attributes) {
665 - my $attrvalue = @Attributes{$attribute};
 771+ foreach my $attribute (keys %Attributes) {
 772+ my $attrvalue = $Attributes{$attribute};
666773
667774 if ($attribute =~ /^Bar$/i) {
668775 $bar = $attrvalue;
@@ -761,13 +868,13 @@
762869 }
763870
764871 if ($bar ne "") {
765 - if (@Axis{"time"} eq "x") { push @Bars, $bar; }
 872+ if ($Axis{"time"} eq "x") { push @Bars, $bar; }
766873 else { unshift @Bars, $bar; }
767874
768 - if ($text ne "") { @BarLegend{ lc($bar) } = $text; }
769 - else { @BarLegend{ lc($bar) } = " "; }
 875+ if ($text ne "") { $BarLegend{ lc($bar) } = $text; }
 876+ else { $BarLegend{ lc($bar) } = " "; }
770877
771 - if ($link ne "") { @BarLink{ lc($bar) } = $link; }
 878+ if ($link ne "") { $BarLink{ lc($bar) } = $link; }
772879 }
773880 else {
774881
@@ -776,11 +883,11 @@
777884 # $bar = $barset . "#" . $b ;
778885
779886 $bar = $barset . "#1";
780 - if (@Axis{"time"} eq "x") { push @Bars, $bar; }
 887+ if ($Axis{"time"} eq "x") { push @Bars, $bar; }
781888 else { unshift @Bars, $bar; }
782889
783 - if ($text ne "") { @BarLegend{ lc($bar) } = $text . " - " . $b; }
784 - else { @BarLegend{ lc($bar) } = " "; }
 890+ if ($text ne "") { $BarLegend{ lc($bar) } = $text . " - " . $b; }
 891+ else { $BarLegend{ lc($bar) } = " "; }
785892
786893 # }
787894 }
@@ -790,6 +897,7 @@
791898 }
792899
793900 sub ParseColors {
 901+ my $colorname;
794902
795903 &GetData;
796904 if ($NoData) {
@@ -809,8 +917,8 @@
810918 my $legendvalue = "";
811919 my $colorvalue = "";
812920
813 - foreach $attribute (keys %Attributes) {
814 - my $attrvalue = @Attributes{$attribute};
 921+ foreach my $attribute (keys %Attributes) {
 922+ my $attrvalue = $Attributes{$attribute};
815923
816924 if ($attribute =~ /Id/i) {
817925 $colorname = $attrvalue;
@@ -924,19 +1032,19 @@
9251033 my $colorname = shift;
9261034 my $colorvalue = shift;
9271035 my $legendvalue = shift;
928 - if (defined(@Colors{ lc($colorname) })) {
 1036+ if (defined($Colors{ lc($colorname) })) {
9291037 &Warning("Color '$colorname' redefined.");
9301038 }
931 - @Colors{ lc($colorname) } = lc($colorvalue);
 1039+ $Colors{ lc($colorname) } = lc($colorvalue);
9321040 if ((defined($legendvalue)) && ($legendvalue ne "")) {
933 - @ColorLabels{ lc($colorname) } = $legendvalue;
 1041+ $ColorLabels{ lc($colorname) } = $legendvalue;
9341042 }
9351043 }
9361044
9371045 sub ParseDateFormat {
9381046 &CheckPreset("DateFormat");
9391047
940 - my $datevalue = lc(@Attributes{"single"});
 1048+ my $datevalue = lc($Attributes{"single"});
9411049 $datevalue =~ s/\s//g;
9421050 $datevalue = lc($datevalue);
9431051 if ( ($datevalue ne "dd/mm/yyyy")
@@ -974,7 +1082,7 @@
9751083 }
9761084
9771085 $value =~ s/($hDollar[a-zA-Z0-9]+)/&GetDefine($command,$1)/ge;
978 - @Consts{ lc($name) } = $value;
 1086+ $Consts{ lc($name) } = $value;
9791087 }
9801088
9811089 sub ParseLineData {
@@ -986,7 +1094,7 @@
9871095 return;
9881096 }
9891097
990 - if ((!(defined($DateFormat))) || (!(defined(@Period{"from"})))) {
 1098+ if ((!(defined($DateFormat))) || (!(defined($Period{"from"})))) {
9911099 if (!(defined($DateFormat))) {
9921100 &Error(
9931101 "LineData invalid. No (valid) command 'DateFormat' specified in previous lines."
@@ -1011,7 +1119,8 @@
10121120 $layer = "front";
10131121 $width = 2.0;
10141122
1015 - my $data2 = $data;
 1123+ # warn "data: $data";
 1124+ my $data2; # = $data;
10161125
10171126 LineData:
10181127 while ((!$InputParsed) && (!$NoData)) {
@@ -1027,26 +1136,26 @@
10281137
10291138 if (!&ValidAttributes("LineData")) { &GetData; next; }
10301139
1031 - if (defined(@LineDefs{"color"})) { $color = @LineDefs{"color"}; }
1032 - if (defined(@LineDefs{"layer"})) { $layer = @LineDefs{"layer"}; }
1033 - if (defined(@LineDefs{"width"})) { $width = @LineDefs{"width"}; }
1034 - if (defined(@LineDefs{"frompos"})) {
1035 - $frompos = @LineDefs{"frompos"};
 1140+ if (defined($LineDefs{"color"})) { $color = $LineDefs{"color"}; }
 1141+ if (defined($LineDefs{"layer"})) { $layer = $LineDefs{"layer"}; }
 1142+ if (defined($LineDefs{"width"})) { $width = $LineDefs{"width"}; }
 1143+ if (defined($LineDefs{"frompos"})) {
 1144+ $frompos = $LineDefs{"frompos"};
10361145 }
1037 - if (defined(@LineDefs{"tillpos"})) {
1038 - $tillpos = @LineDefs{"tillpos"};
 1146+ if (defined($LineDefs{"tillpos"})) {
 1147+ $tillpos = $LineDefs{"tillpos"};
10391148 }
1040 - if (defined(@LineDefs{"atpos"})) { $atpos = @LineDefs{"atpos"}; }
 1149+ if (defined($LineDefs{"atpos"})) { $atpos = $LineDefs{"atpos"}; }
10411150
1042 - foreach $attribute (keys %Attributes) {
1043 - my $attrvalue = @Attributes{$attribute};
 1151+ foreach my $attribute (keys %Attributes) {
 1152+ my $attrvalue = $Attributes{$attribute};
10441153
10451154 if ($attribute =~ /^(?:At|From|Till)$/i) {
10461155 if ($attrvalue =~ /^Start$/i) {
1047 - $attrvalue = @Period{"from"};
 1156+ $attrvalue = $Period{"from"};
10481157 }
10491158
1050 - if ($attrvalue =~ /^End$/i) { $attrvalue = @Period{"till"}; }
 1159+ if ($attrvalue =~ /^End$/i) { $attrvalue = $Period{"till"}; }
10511160
10521161 if (!&ValidDateFormat($attrvalue)) {
10531162 &Error( "LineData attribute '$attribute' invalid.\n"
@@ -1101,7 +1210,7 @@
11021211 }
11031212 elsif ($attribute =~ /Color/i) {
11041213 if ( (!&ColorPredefined($attrvalue))
1105 - && (!defined(@Colors{ lc($attrvalue) })))
 1214+ && (!defined($Colors{ lc($attrvalue) })))
11061215 {
11071216 &Error(
11081217 "LineData attribute '$attribute' invalid. Unknown color '$attrvalue'.\n"
@@ -1112,7 +1221,7 @@
11131222 }
11141223
11151224 if (!&ColorPredefined($attrvalue)) {
1116 - $attrvalue = @Colors{ lc($attrvalue) };
 1225+ $attrvalue = $Colors{ lc($attrvalue) };
11171226 }
11181227
11191228 $color = $attrvalue;
@@ -1168,12 +1277,12 @@
11691278 && ($till eq "")
11701279 && ($points eq "")) # upd defaults
11711280 {
1172 - if ($color ne "") { @LineDefs{"color"} = $color; }
1173 - if ($layer ne "") { @LineDefs{"layer"} = $layer; }
1174 - if ($width ne "") { @LineDefs{"width"} = $width; }
1175 - if ($atpos ne "") { @LineDefs{"atpos"} = $atpos; }
1176 - if ($frompos ne "") { @LineDefs{"frompos"} = $frompos; }
1177 - if ($tillpos ne "") { @LineDefs{"tillpos"} = $tillpos; }
 1281+ if ($color ne "") { $LineDefs{"color"} = $color; }
 1282+ if ($layer ne "") { $LineDefs{"layer"} = $layer; }
 1283+ if ($width ne "") { $LineDefs{"width"} = $width; }
 1284+ if ($atpos ne "") { $LineDefs{"atpos"} = $atpos; }
 1285+ if ($frompos ne "") { $LineDefs{"frompos"} = $frompos; }
 1286+ if ($tillpos ne "") { $LineDefs{"tillpos"} = $tillpos; }
11781287 }
11791288
11801289 if ($layer eq "") { $layer = "back"; }
@@ -1247,8 +1356,8 @@
12481357
12491358 &CheckPreset("ImageSize");
12501359
1251 - foreach $attribute (keys %Attributes) {
1252 - my $attrvalue = @Attributes{$attribute};
 1360+ foreach my $attribute (keys %Attributes) {
 1361+ my $attrvalue = $Attributes{$attribute};
12531362
12541363 if ($attribute =~ /Width|Height/i) {
12551364 if ($attrvalue !~ /auto/i) {
@@ -1269,19 +1378,19 @@
12701379 return;
12711380 }
12721381
1273 - @Attributes{"barinc"} = $attrvalue;
 1382+ $Attributes{"barinc"} = $attrvalue;
12741383 }
12751384
12761385 # if ($attribute =~ /Width/i)
1277 - # { @Attributes {"width"} = $attrvalue ; }
 1386+ # { $Attributes{"width"} = $attrvalue ; }
12781387 # elsif ($attribute =~ /Height/i)
1279 - # { @Attributes {"height"} = $attrvalue ; }
 1388+ # { $Attributes{"height"} = $attrvalue ; }
12801389 }
12811390
1282 - if ( (@Attributes{"width"} =~ /auto/i)
1283 - || (@Attributes{"height"} =~ /auto/i))
 1391+ if ( ($Attributes{"width"} =~ /auto/i)
 1392+ || ($Attributes{"height"} =~ /auto/i))
12841393 {
1285 - if (@Attributes{"barinc"} eq "") {
 1394+ if ($Attributes{"barinc"} eq "") {
12861395 &Error( "ImageSize attribute 'barincrement' missing.\n"
12871396 . "Automatic determination of image width or height implies specification of this attribute"
12881397 );
@@ -1289,10 +1398,10 @@
12901399 }
12911400 }
12921401
1293 - if ( (@Attributes{"width"} !~ /auto/i)
1294 - && (@Attributes{"height"} !~ /auto/i))
 1402+ if ( ($Attributes{"width"} !~ /auto/i)
 1403+ && ($Attributes{"height"} !~ /auto/i))
12951404 {
1296 - if (@Attributes{"barinc"} ne "") {
 1405+ if ($Attributes{"barinc"} ne "") {
12971406 &Error( "ImageSize attribute 'barincrement' not valid now.\n"
12981407 . "This attribute is only valid (and mandatory) in combination with 'width:auto' or 'height:auto'"
12991408 );
@@ -1308,8 +1417,8 @@
13091418
13101419 &CheckPreset("Legend");
13111420
1312 - foreach $attribute (keys %Attributes) {
1313 - my $attrvalue = @Attributes{$attribute};
 1421+ foreach my $attribute (keys %Attributes) {
 1422+ my $attrvalue = $Attributes{$attribute};
13141423
13151424 if ($attribute =~ /Columns/i) {
13161425 if (($attrvalue < 1) || ($attrvalue > 4)) {
@@ -1326,7 +1435,7 @@
13271436 return;
13281437 }
13291438
1330 - @Attributes{"orientation"} = substr($attrvalue, 0, 3);
 1439+ $Attributes{"orientation"} = substr($attrvalue, 0, 3);
13311440 }
13321441 elsif ($attribute =~ /Position/i) {
13331442 if (!($attrvalue =~ /^(?:top|bottom|right)$/i)) {
@@ -1362,8 +1471,8 @@
13631472 }
13641473 }
13651474
1366 - if (defined(@Attributes{"position"})) {
1367 - if (defined(@Attributes{"left"})) {
 1475+ if (defined($Attributes{"position"})) {
 1476+ if (defined($Attributes{"left"})) {
13681477 &Error(
13691478 "Legend definition invalid. Attributes 'position' and 'left' are mutually exclusive."
13701479 );
@@ -1371,15 +1480,15 @@
13721481 }
13731482 }
13741483 else {
1375 - if ((!defined(@Attributes{"left"})) && (!defined(@Attributes{"top"})))
 1484+ if ((!defined($Attributes{"left"})) && (!defined($Attributes{"top"})))
13761485 {
13771486 &Info(
13781487 "Legend definition: none of attributes 'position', 'left' or 'top' have been defined. Position 'bottom' assumed."
13791488 );
1380 - @Attributes{"position"} = "bottom";
 1489+ $Attributes{"position"} = "bottom";
13811490 }
1382 - elsif ((!defined(@Attributes{"left"}))
1383 - || (!defined(@Attributes{"top"})))
 1491+ elsif ((!defined($Attributes{"left"}))
 1492+ || (!defined($Attributes{"top"})))
13841493 {
13851494 &Error(
13861495 "Legend definition invalid. Specify 'position', or 'left' & 'top'."
@@ -1388,14 +1497,14 @@
13891498 }
13901499 }
13911500
1392 - if (@Attributes{"position"} =~ /right/i) {
1393 - if (defined(@Attributes{"columns"})) {
 1501+ if ($Attributes{"position"} =~ /right/i) {
 1502+ if (defined($Attributes{"columns"})) {
13941503 &Error(
13951504 "Legend definition invalid.\nAttribute 'columns' and 'position:right' are mutually exclusive."
13961505 );
13971506 return;
13981507 }
1399 - if (defined(@Attributes{"columnwidth"})) {
 1508+ if (defined($Attributes{"columnwidth"})) {
14001509 &Error(
14011510 "Legend definition invalid.\nAttribute 'columnwidth' and 'position:right' are mutually exclusive."
14021511 );
@@ -1403,20 +1512,20 @@
14041513 }
14051514 }
14061515
1407 - if (@Attributes{"orientation"} =~ /hor/i) {
1408 - if (@Attributes{"position"} =~ /right/i) {
 1516+ if ($Attributes{"orientation"} =~ /hor/i) {
 1517+ if ($Attributes{"position"} =~ /right/i) {
14091518 &Error(
14101519 "Legend definition invalid.\n'position:right' and 'orientation:horizontal' are mutually exclusive."
14111520 );
14121521 return;
14131522 }
1414 - if (defined(@Attributes{"columns"})) {
 1523+ if (defined($Attributes{"columns"})) {
14151524 &Error(
14161525 "Legend definition invalid.\nAttribute 'columns' and 'orientation:horizontal' are mutually exclusive."
14171526 );
14181527 return;
14191528 }
1420 - if (defined(@Attributes{"columnwidth"})) {
 1529+ if (defined($Attributes{"columnwidth"})) {
14211530 &Error(
14221531 "Legend definition invalid.\nAttribute 'columnwidth' and 'orientation:horizontal' are mutually exclusive."
14231532 );
@@ -1424,8 +1533,8 @@
14251534 }
14261535 }
14271536
1428 - if ( (@Attributes{"orientation"} =~ /hor/i)
1429 - && (defined(@Attributes{"columns"})))
 1537+ if ( ($Attributes{"orientation"} =~ /hor/i)
 1538+ && (defined($Attributes{"columns"})))
14301539 {
14311540 &Error(
14321541 "Legend definition invalid.\nDo not specify attribute 'columns' with 'orientation:horizontal'."
@@ -1433,9 +1542,9 @@
14341543 return;
14351544 }
14361545
1437 - if (@Attributes{"columns"} > 1) {
1438 - if ( (defined(@Attributes{"left"}))
1439 - && (!defined(@Attributes{"columnwidth"})))
 1546+ if ($Attributes{"columns"} > 1) {
 1547+ if ( (defined($Attributes{"left"}))
 1548+ && (!defined($Attributes{"columnwidth"})))
14401549 {
14411550 &Error(
14421551 "Legend attribute 'columnwidth' not defined.\nThis is needed when attribute 'left' is specified."
@@ -1444,8 +1553,8 @@
14451554 }
14461555 }
14471556
1448 - if (!defined(@Attributes{"orientation"})) {
1449 - @Attributes{"orientation"} = "ver";
 1557+ if (!defined($Attributes{"orientation"})) {
 1558+ $Attributes{"orientation"} = "ver";
14501559 }
14511560
14521561 %Legend = %Attributes;
@@ -1461,8 +1570,8 @@
14621571
14631572 if (!ValidAttributes("Period")) { return; }
14641573
1465 - foreach $attribute (keys %Attributes) {
1466 - my $attrvalue = @Attributes{$attribute};
 1574+ foreach my $attribute (keys %Attributes) {
 1575+ my $attrvalue = $Attributes{$attribute};
14671576
14681577 if ($DateFormat eq "yyyy") {
14691578 if ($attrvalue !~ /^\-?\d+$/) {
@@ -1496,8 +1605,7 @@
14971606 }
14981607 }
14991608
1500 - $ValidDate = &ValidDateFormat($attrvalue);
1501 - if (!$ValidDate) {
 1609+ if (!&ValidDateFormat($attrvalue)) {
15021610 &Error( "Period attribute '$attribute' invalid.\n"
15031611 . "Date does not conform to specified DateFormat '$DateFormat'."
15041612 );
@@ -1510,7 +1618,7 @@
15111619 return;
15121620 }
15131621
1514 - @Attributes{$attribute} = $attrvalue;
 1622+ $Attributes{$attribute} = $attrvalue;
15151623 }
15161624 }
15171625
@@ -1518,12 +1626,14 @@
15191627 }
15201628
15211629 sub ParsePlotArea {
1522 - if (!&ValidAttributes("PlotArea")) { return; }
 1630+ if (!&ValidAttributes("PlotArea")) {
 1631+ return;
 1632+ }
15231633
15241634 &CheckPreset("PlotArea");
15251635
1526 - foreach $attribute (@Attributes) {
1527 - my $attrvalue = @Attributes{$attribute};
 1636+ foreach my $attribute (@Attributes) {
 1637+ my $attrvalue = $Attributes{$attribute};
15281638 if (!&ValidAbsRel($attrvalue)) {
15291639 &Error( "PlotArea attribute '$attribute' invalid.\n"
15301640 . "Specify value as x[.y][px, in, cm, %] examples: '200', '20px', '1.3in', '80%'"
@@ -1532,28 +1642,28 @@
15331643 }
15341644 }
15351645
1536 - if ((@Attributes{"top"} ne "") && (@Attributes{"height"} ne "")) {
 1646+ if (($Attributes{"top"} ne "") && ($Attributes{"height"} ne "")) {
15371647 &Error(
15381648 "PlotArea attributes 'top' and 'height' are mutually exclusive. Specify only one of them."
15391649 );
15401650 return;
15411651 }
15421652
1543 - if ((@Attributes{"right"} ne "") && (@Attributes{"width"} ne "")) {
 1653+ if (($Attributes{"right"} ne "") && ($Attributes{"width"} ne "")) {
15441654 &Error(
15451655 "PlotArea attributes 'right' and 'width' are mutually exclusive. Specify only one of them."
15461656 );
15471657 return;
15481658 }
15491659
1550 - if ((@Attributes{"top"} eq "") && (@Attributes{"height"} eq "")) {
 1660+ if (($Attributes{"top"} eq "") && ($Attributes{"height"} eq "")) {
15511661 &Error(
15521662 "PlotArea definition incomplete. Either attribute 'top' (advised) or 'height' should be specified"
15531663 );
15541664 return;
15551665 }
15561666
1557 - if ((@Attributes{"right"} eq "") && (@Attributes{"width"} eq "")) {
 1667+ if (($Attributes{"right"} eq "") && ($Attributes{"width"} eq "")) {
15581668 &Error(
15591669 "PlotArea definition incomplete. Either attribute 'right' (advised) or 'width' should be specified"
15601670 );
@@ -1574,24 +1684,25 @@
15751685 # | bar: |== 0 | - | assume | |
15761686 # | | assume bar:--- | | bar:--- | |
15771687 # | |== 1 |
1578 -# | | assume @Bar[0] |
 1688+# | | assume $Bar[0] |
15791689 # | |> 1 |
15801690 # | | err |
15811691 sub ParsePlotData {
1582 - if (defined(@Bars)) { $BarsCommandFound = $true; }
1583 - else { $BarsCommandFound = $false; }
1584 - $prevbar = "";
 1692+ my $attrvalue2;
 1693+ my $BarsCommandFound = @Bars;
 1694+ my $prevbar = "";
 1695+ my $barndx;
15851696
15861697 if ( (!(defined($DateFormat)))
1587 - || (@Period{"from"} eq "")
1588 - || (@Axis{"time"} eq ""))
 1698+ || ($Period{"from"} eq "")
 1699+ || ($Axis{"time"} eq ""))
15891700 {
15901701 if (!(defined($DateFormat))) {
15911702 &Error(
15921703 "PlotData invalid. No (valid) command 'DateFormat' specified in previous lines."
15931704 );
15941705 }
1595 - elsif (@Period{"from"} eq "") {
 1706+ elsif ($Period{"from"} eq "") {
15961707 &Error(
15971708 "PlotData invalid. No (valid) command 'Period' specified in previous lines."
15981709 );
@@ -1622,7 +1733,7 @@
16231734 $mark, $markcolor, $link, $hint
16241735 );
16251736
1626 - @PlotDefs{"anchor"} = "middle";
 1737+ $PlotDefs{"anchor"} = "middle";
16271738
16281739 PlotData:
16291740 while ((!$InputParsed) && (!$NoData)) {
@@ -1650,34 +1761,34 @@
16511762
16521763 &CheckPreset("PlotData");
16531764
1654 - if (defined(@PlotDefs{"bar"})) { $bar = @PlotDefs{"bar"}; }
 1765+ if (defined($PlotDefs{"bar"})) { $bar = $PlotDefs{"bar"}; }
16551766
1656 - # if (defined (@PlotDefs {"barset"})) { $barset = @PlotDefs {"barset"} ; }
1657 - if (defined(@PlotDefs{"color"})) { $color = @PlotDefs{"color"}; }
1658 - if (defined(@PlotDefs{"bgcolor"})) {
1659 - $bgcolor = @PlotDefs{"bgcolor"};
 1767+ # if (defined ($PlotDefs{"barset"})) { $barset = $PlotDefs{"barset"} ; }
 1768+ if (defined($PlotDefs{"color"})) { $color = $PlotDefs{"color"}; }
 1769+ if (defined($PlotDefs{"bgcolor"})) {
 1770+ $bgcolor = $PlotDefs{"bgcolor"};
16601771 }
1661 - if (defined(@PlotDefs{"textcolor"})) {
1662 - $textcolor = @PlotDefs{"textcolor"};
 1772+ if (defined($PlotDefs{"textcolor"})) {
 1773+ $textcolor = $PlotDefs{"textcolor"};
16631774 }
1664 - if (defined(@PlotDefs{"fontsize"})) {
1665 - $fontsize = @PlotDefs{"fontsize"};
 1775+ if (defined($PlotDefs{"fontsize"})) {
 1776+ $fontsize = $PlotDefs{"fontsize"};
16661777 }
1667 - if (defined(@PlotDefs{"width"})) { $width = @PlotDefs{"width"}; }
1668 - if (defined(@PlotDefs{"anchor"})) { $anchor = @PlotDefs{"anchor"}; }
1669 - if (defined(@PlotDefs{"align"})) { $align = @PlotDefs{"align"}; }
1670 - if (defined(@PlotDefs{"shiftx"})) { $shiftx = @PlotDefs{"shiftx"}; }
1671 - if (defined(@PlotDefs{"shifty"})) { $shifty = @PlotDefs{"shifty"}; }
1672 - if (defined(@PlotDefs{"mark"})) { $mark = @PlotDefs{"mark"}; }
1673 - if (defined(@PlotDefs{"markcolor"})) {
1674 - $markcolor = @PlotDefs{"markcolor"};
 1778+ if (defined($PlotDefs{"width"})) { $width = $PlotDefs{"width"}; }
 1779+ if (defined($PlotDefs{"anchor"})) { $anchor = $PlotDefs{"anchor"}; }
 1780+ if (defined($PlotDefs{"align"})) { $align = $PlotDefs{"align"}; }
 1781+ if (defined($PlotDefs{"shiftx"})) { $shiftx = $PlotDefs{"shiftx"}; }
 1782+ if (defined($PlotDefs{"shifty"})) { $shifty = $PlotDefs{"shifty"}; }
 1783+ if (defined($PlotDefs{"mark"})) { $mark = $PlotDefs{"mark"}; }
 1784+ if (defined($PlotDefs{"markcolor"})) {
 1785+ $markcolor = $PlotDefs{"markcolor"};
16751786 }
16761787
1677 - # if (defined (@PlotDefs {"link"})) { $link = @PlotDefs {"link"} ; }
1678 - # if (defined (@PlotDefs {"hint"})) { $hint = @PlotDefs {"hint"} ; }
 1788+ # if (defined ($PlotDefs{"link"})) { $link = $PlotDefs{"link"} ; }
 1789+ # if (defined ($PlotDefs{"hint"})) { $hint = $PlotDefs{"hint"} ; }
16791790
1680 - foreach $attribute (keys %Attributes) {
1681 - my $attrvalue = @Attributes{$attribute};
 1791+ foreach my $attribute (keys %Attributes) {
 1792+ my $attrvalue = $Attributes{$attribute};
16821793
16831794 if ($attribute =~ /^Bar$/i) {
16841795 if (!($attrvalue =~ /[a-zA-Z0-9\_]+/)) {
@@ -1701,8 +1812,12 @@
17021813 }
17031814 else {
17041815 if (!&BarDefined($attrvalue2)) {
1705 - if (@Axis{"time"} eq "x") { push @Bars, $attrvalue2; }
1706 - else { unshift @Bars, $attrvalue2; }
 1816+ if ($Axis{"time"} eq "x") {
 1817+ push @Bars, $attrvalue2;
 1818+ }
 1819+ else {
 1820+ unshift @Bars, $attrvalue2;
 1821+ }
17071822 }
17081823 }
17091824 $bar = $attrvalue2;
@@ -1719,7 +1834,9 @@
17201835
17211836 $attrvalue2 = $attrvalue;
17221837
1723 - if ($attrvalue =~ /break/i) { $barndx = 0; }
 1838+ if ($attrvalue =~ /break/i) {
 1839+ $barndx = 0;
 1840+ }
17241841 elsif ($attrvalue =~ /skip/i) {
17251842 $barndx++;
17261843 &BarDefined($prevbar . "#" . $barndx);
@@ -1741,9 +1858,9 @@
17421859 }
17431860 elsif ($attribute =~ /^(?:At|From|Till)$/i) {
17441861 if ($attrvalue =~ /^Start$/i) {
1745 - $attrvalue = @Period{"from"};
 1862+ $attrvalue = $Period{"from"};
17461863 }
1747 - if ($attrvalue =~ /^End$/i) { $attrvalue = @Period{"till"}; }
 1864+ if ($attrvalue =~ /^End$/i) { $attrvalue = $Period{"till"}; }
17481865
17491866 if (!&ValidDateFormat($attrvalue)) {
17501867 &Error( "PlotData attribute '$attribute' invalid.\n"
@@ -1770,7 +1887,7 @@
17711888 # elsif ($attribute =~ /^From$/i)
17721889 # {
17731890 # if ($attrvalue =~ /^Start$/i)
1774 - # { $attrvalue = @Period {"from"} ; }
 1891+ # { $attrvalue = $Period{"from"} ; }
17751892
17761893 # if (! &ValidDateFormat ($attrvalue))
17771894 # { &Error ("PlotData invalid.\nDate '$attrvalue' does not conform to specified DateFormat $DateFormat.") ;
@@ -1786,7 +1903,7 @@
17871904 # elsif ($attribute =~ /^Till$/i)
17881905 # {
17891906 # if ($attrvalue =~ /^End$/i)
1790 - # { $attrvalue = @Period {"till"} ; }
 1907+ # { $attrvalue = $Period{"till"} ; }
17911908
17921909 # if (! &ValidDateFormat ($attrvalue))
17931910 # { &Error ("PlotData invalid. Date '$attrvalue' does not conform to specified DateFormat $DateFormat.") ;
@@ -1801,7 +1918,7 @@
18021919 # }
18031920 elsif ($attribute =~ /^Color$/i) {
18041921 if (!&ColorPredefined($attrvalue)) {
1805 - if (!defined(@Colors{ lc($attrvalue) })) {
 1922+ if (!defined($Colors{ lc($attrvalue) })) {
18061923 &Error(
18071924 "PlotData invalid. Attribute '$attribute' has unknown color '$attrvalue'.\n"
18081925 . " Specify command 'Color' before this command."
@@ -1810,8 +1927,8 @@
18111928 next PlotData;
18121929 }
18131930 }
1814 - if (defined(@Colors{ lc($attrvalue) })) {
1815 - $color = @Colors{ lc($attrvalue) };
 1931+ if (defined($Colors{ lc($attrvalue) })) {
 1932+ $color = $Colors{ lc($attrvalue) };
18161933 }
18171934 else { $color = lc($attrvalue); }
18181935
@@ -1819,7 +1936,7 @@
18201937 }
18211938 elsif ($attribute =~ /^BgColor$/i) {
18221939 if (!&ColorPredefined($attrvalue)) {
1823 - if (!defined(@Colors{ lc($attrvalue) })) {
 1940+ if (!defined($Colors{ lc($attrvalue) })) {
18241941 &Error(
18251942 "PlotData invalid. Attribute '$attribute' has unknown color '$attrvalue'.\n"
18261943 . " Specify command 'Color' before this command."
@@ -1828,14 +1945,14 @@
18291946 next PlotData;
18301947 }
18311948 }
1832 - if (defined(@Colors{ lc($attrvalue) })) {
1833 - $bgcolor = @Colors{ lc($attrvalue) };
 1949+ if (defined($Colors{ lc($attrvalue) })) {
 1950+ $bgcolor = $Colors{ lc($attrvalue) };
18341951 }
18351952 else { $bgcolor = lc($attrvalue); }
18361953 }
18371954 elsif ($attribute =~ /^TextColor$/i) {
18381955 if (!&ColorPredefined($attrvalue)) {
1839 - if (!defined(@Colors{ lc($attrvalue) })) {
 1956+ if (!defined($Colors{ lc($attrvalue) })) {
18401957 &Error(
18411958 "PlotData invalid. Attribute '$attribute' contains unknown color '$attrvalue'.\n"
18421959 . " Specify command 'Color' before this command."
@@ -1844,8 +1961,8 @@
18451962 next PlotData;
18461963 }
18471964 }
1848 - if (defined(@Colors{ lc($attrvalue) })) {
1849 - $textcolor = @Colors{ lc($attrvalue) };
 1965+ if (defined($Colors{ lc($attrvalue) })) {
 1966+ $textcolor = $Colors{ lc($attrvalue) };
18501967 }
18511968 else { $textcolor = lc($attrvalue); }
18521969 }
@@ -1908,7 +2025,7 @@
19092026 $shift = $attrvalue;
19102027 $shift =~ s/$hBrO(.*?)$hBrC/$1/;
19112028 $shift =~ s/\s//g;
1912 - ($shiftx2, $shifty2) = split(",", $shift);
 2029+ my ($shiftx2, $shifty2) = split(",", $shift);
19132030 if ($shiftx2 ne "") { $shiftx = &Normalize($shiftx2); }
19142031 if ($shifty2 ne "") { $shifty = &Normalize($shifty2); }
19152032
@@ -1949,8 +2066,8 @@
19502067 # }
19512068 elsif ($attribute =~ /^Mark$/i) {
19522069 $attrvalue =~ s/$hBrO (.*) $hBrC/$1/x;
1953 - (@suboptions) = split(",", $attrvalue);
1954 - $mark = @suboptions[0];
 2070+ my (@suboptions) = split(",", $attrvalue);
 2071+ $mark = $suboptions[0];
19552072 if (!($mark =~ /^(?:Line|None)$/i)) {
19562073 &Error(
19572074 "PlotData invalid. Value '$mark' for attribute 'mark' unknown."
@@ -1959,11 +2076,11 @@
19602077 next PlotData;
19612078 }
19622079
1963 - if (defined(@suboptions[1])) {
1964 - $markcolor = @suboptions[1];
 2080+ if (defined($suboptions[1])) {
 2081+ $markcolor = $suboptions[1];
19652082
19662083 if (!&ColorPredefined($markcolor)) {
1967 - if (!defined(@Colors{ lc($markcolor) })) {
 2084+ if (!defined($Colors{ lc($markcolor) })) {
19682085 &Error(
19692086 "PlotData invalid. Attribute 'mark': unknown color '$markcolor'.\n"
19702087 . " Specify command 'Color' before this command."
@@ -1997,33 +2114,33 @@
19982115 if ($MaxBarWidth eq "") { $MaxBarWidth = $width - 0.001; }
19992116
20002117 if ($bar ne "") {
2001 - if (!defined(@BarLegend{ lc($bar) })) {
2002 - @BarLegend{ lc($bar) } = $bar;
 2118+ if (!defined($BarLegend{ lc($bar) })) {
 2119+ $BarLegend{ lc($bar) } = $bar;
20032120 }
2004 - if (!defined(@BarWidths{$bar})) {
2005 - @BarWidths{$bar} = $width;
 2121+ if (!defined($BarWidths{$bar})) {
 2122+ $BarWidths{$bar} = $width;
20062123 } # was 0 ??
20072124 }
20082125
20092126 if (($at eq "") && ($from eq "") && ($till eq "")) # upd defaults
20102127 {
2011 - if ($bar ne "") { @PlotDefs{"bar"} = $bar; }
 2128+ if ($bar ne "") { $PlotDefs{"bar"} = $bar; }
20122129
2013 - # if ($barset ne "") { @PlotDefs {"barset"} = $barset ; }
2014 - if ($color ne "") { @PlotDefs{"color"} = $color; }
2015 - if ($bgcolor ne "") { @PlotDefs{"bgcolor"} = $bgcolor; }
2016 - if ($textcolor ne "") { @PlotDefs{"textcolor"} = $textcolor; }
2017 - if ($fontsize ne "") { @PlotDefs{"fontsize"} = $fontsize; }
2018 - if ($width ne "") { @PlotDefs{"width"} = $width; }
2019 - if ($anchor ne "") { @PlotDefs{"anchor"} = $anchor; }
2020 - if ($align ne "") { @PlotDefs{"align"} = $align; }
2021 - if ($shiftx ne "") { @PlotDefs{"shiftx"} = $shiftx; }
2022 - if ($shifty ne "") { @PlotDefs{"shifty"} = $shifty; }
2023 - if ($mark ne "") { @PlotDefs{"mark"} = $mark; }
2024 - if ($markcolor ne "") { @PlotDefs{"markcolor"} = $markcolor; }
 2130+ # if ($barset ne "") { $PlotDefs{"barset"} = $barset ; }
 2131+ if ($color ne "") { $PlotDefs{"color"} = $color; }
 2132+ if ($bgcolor ne "") { $PlotDefs{"bgcolor"} = $bgcolor; }
 2133+ if ($textcolor ne "") { $PlotDefs{"textcolor"} = $textcolor; }
 2134+ if ($fontsize ne "") { $PlotDefs{"fontsize"} = $fontsize; }
 2135+ if ($width ne "") { $PlotDefs{"width"} = $width; }
 2136+ if ($anchor ne "") { $PlotDefs{"anchor"} = $anchor; }
 2137+ if ($align ne "") { $PlotDefs{"align"} = $align; }
 2138+ if ($shiftx ne "") { $PlotDefs{"shiftx"} = $shiftx; }
 2139+ if ($shifty ne "") { $PlotDefs{"shifty"} = $shifty; }
 2140+ if ($mark ne "") { $PlotDefs{"mark"} = $mark; }
 2141+ if ($markcolor ne "") { $PlotDefs{"markcolor"} = $markcolor; }
20252142
2026 - # if ($link ne "") { @PlotDefs {"link"} = $link ; }
2027 - # if ($hint ne "") { @PlotDefs {"hint"} = $hint ; }
 2143+ # if ($link ne "") { $PlotDefs{"link"} = $link ; }
 2144+ # if ($hint ne "") { $PlotDefs{"hint"} = $hint ; }
20282145 &GetData;
20292146 next PlotData;
20302147 }
@@ -2040,27 +2157,15 @@
20412158 next PlotData;
20422159 }
20432160 elsif ($#Bars == 0) {
2044 - $bar = @Bars[0];
2045 - &Info($data,
 2161+ $bar = $Bars[0];
 2162+ # warn "data: $data";
 2163+ &Info(q(), # $data,
20462164 "PlotData incomplete. Attribute 'bar' missing, value '"
2047 - . @Bars[0]
 2165+ . $Bars[0]
20482166 . "' assumed.");
20492167 }
20502168 else { $bar = "1"; }
20512169
2052 - # }
2053 - # else
2054 - # {
2055 - # if ($#Bars > 0)
2056 - # { &Error ("PlotData invalid. Attribute 'bar' missing.") ;
2057 - # &GetData ; next PlotData ; }
2058 - # elsif ($#Bars == 0)
2059 - # {
2060 - # $bar = @Bars [0] ;
2061 - # &Info ($data, "PlotData incomplete. Attribute 'bar' missing, value '" . @Bars [0] . "' assumed.") ;
2062 - # }
2063 - # else { $bar = "1" ; }
2064 - # }
20652170 $prevbar = $bar;
20662171 }
20672172 }
@@ -2144,7 +2249,7 @@
21452250 push @PlotBars,
21462251 sprintf("%6.3f,%s,%s,%s,%s,%s,%s,\n",
21472252 $width, $bar, $from, $till, lc($color), $link, $hint);
2148 - if ($width > @BarWidths{$bar}) { @BarWidths{$bar} = $width; }
 2253+ if ($width > $BarWidths{$bar}) { $BarWidths{$bar} = $width; }
21492254
21502255 if ($text ne "") {
21512256 if ($anchor eq "from") { $at = $from; }
@@ -2187,7 +2292,8 @@
21882293 if ($align eq "") { $align = "center"; }
21892294 if ($color eq "") { $color = "black"; }
21902295 if ($fontsize eq "") { $fontsize = "S"; }
2191 - if ($adjust eq "") { $adjust = "0,0"; }
 2296+ # $adjust Doesn't seem to be used anywhere
 2297+ # if ($adjust eq "") { $adjust = "0,0"; }
21922298
21932299 # $textdetails = " textdetails: align=$align size=$size" ;
21942300 # if ($textcolor eq "")
@@ -2199,11 +2305,11 @@
22002306 # my $barcnt = 0 ;
22012307 # for ($b = 0 ; $b <= $#Bars ; $b++)
22022308 # {
2203 - # if (lc(@Bars [$b]) eq lc($bar))
 2309+ # if (lc($Bars[$b]) eq lc($bar))
22042310 # { $barcnt = ($b + 1) ; last ; }
22052311 # }
22062312
2207 - # if (@Axis {"time"} eq "x")
 2313+ # if ($Axis{"time"} eq "x")
22082314 # { $xpos = "$at(s)" ; $ypos = "[$barcnt](s)" ; }
22092315 # else
22102316 # { $ypos = "$at(s)" ; $xpos = "[$barcnt](s)" ; }
@@ -2246,18 +2352,19 @@
22472353 }
22482354
22492355 $maxwidth = 0;
 2356+ my $key;
22502357 foreach $key (keys %BarWidths) {
2251 - if (@BarWidths{$key} == 0) {
 2358+ if ($BarWidths{$key} == 0) {
22522359 &Warning(
22532360 "PlotData incomplete. No bar width defined for bar '$key', assume width from widest bar (used for line marks)."
22542361 );
22552362 }
2256 - elsif (@BarWidths{$key} > $maxwidth) {
2257 - $maxwidth = @BarWidths{$key};
 2363+ elsif ($BarWidths{$key} > $maxwidth) {
 2364+ $maxwidth = $BarWidths{$key};
22582365 }
22592366 }
22602367 foreach $key (keys %BarWidths) {
2261 - if (@BarWidths{$key} == 0) { @BarWidths{$key} = $maxwidth; }
 2368+ if ($BarWidths{$key} == 0) { $BarWidths{$key} = $maxwidth; }
22622369 }
22632370 }
22642371
@@ -2269,7 +2376,7 @@
22702377 return;
22712378 }
22722379
2273 - $preset = @Attributes{"single"};
 2380+ my $preset = $Attributes{"single"};
22742381 if ($preset !~
22752382 /^(?:TimeVertical_OneBar_UnitYear|TimeHorizontal_AutoPlaceBars_UnitYear)$/i
22762383 )
@@ -2286,20 +2393,20 @@
22872394 if ($Preset =~ /^TimeVertical_OneBar_UnitYear/i) {
22882395 $DateFormat = "yyyy";
22892396 $AlignBars = "early";
2290 - @Axis{"format"} = "yyyy";
2291 - @Axis{"time"} = "y";
2292 - @PlotArea{"left"} = 45;
2293 - @PlotArea{"right"} = 10;
2294 - @PlotArea{"top"} = 10;
2295 - @PlotArea{"bottom"} = 10;
2296 - push @PresetList, "PlotArea|+|left|" . @PlotArea{"left"};
2297 - push @PresetList, "PlotArea|+|right|" . @PlotArea{"right"};
2298 - push @PresetList, "PlotArea|+|top|" . @PlotArea{"top"};
2299 - push @PresetList, "PlotArea|+|bottom|" . @PlotArea{"bottom"};
 2397+ $Axis{"format"} = "yyyy";
 2398+ $Axis{"time"} = "y";
 2399+ $PlotArea{"left"} = 45;
 2400+ $PlotArea{"right"} = 10;
 2401+ $PlotArea{"top"} = 10;
 2402+ $PlotArea{"bottom"} = 10;
 2403+ push @PresetList, "PlotArea|+|left|" . $PlotArea{"left"};
 2404+ push @PresetList, "PlotArea|+|right|" . $PlotArea{"right"};
 2405+ push @PresetList, "PlotArea|+|top|" . $PlotArea{"top"};
 2406+ push @PresetList, "PlotArea|+|bottom|" . $PlotArea{"bottom"};
23002407 push @PresetList, "PlotArea|-|width";
23012408 push @PresetList, "PlotArea|-|height";
23022409 push @PresetList, "Dateformat|-||yyyy";
2303 - push @PresetList, "TimeAxis|=|format|" . @Axis{"format"};
 2410+ push @PresetList, "TimeAxis|=|format|" . $Axis{"format"};
23042411 push @PresetList, "TimeAxis|=|orientation|vertical";
23052412 push @PresetList, "ScaleMajor|=|unit|year";
23062413 push @PresetList, "ScaleMinor|=|unit|year";
@@ -2313,39 +2420,39 @@
23142421 elsif ($Preset =~ /TimeHorizontal_AutoPlaceBars_UnitYear/i) {
23152422 $DateFormat = "yyyy";
23162423 $AlignBars = "justify";
2317 - @Axis{"format"} = "yyyy";
2318 - @Axis{"time"} = "x";
2319 - @PlotArea{"left"} = 25;
2320 - @PlotArea{"right"} = 25;
2321 - @PlotArea{"top"} = 15;
2322 - @PlotArea{"bottom"} = 30;
2323 - @Image{"height"} = "auto";
2324 - @Image{"barinc"} = 20;
2325 - @BackgroundColors{"canvas"} = "gray(0.7)";
2326 - @Legend{"orientation"} = "ver";
2327 - @Legend{"left"} = @PlotArea{"left"} + 10;
2328 - @Legend{"top"} = @PlotArea{"bottom"} + 100;
 2424+ $Axis{"format"} = "yyyy";
 2425+ $Axis{"time"} = "x";
 2426+ $PlotArea{"left"} = 25;
 2427+ $PlotArea{"right"} = 25;
 2428+ $PlotArea{"top"} = 15;
 2429+ $PlotArea{"bottom"} = 30;
 2430+ $Image{"height"} = "auto";
 2431+ $Image{"barinc"} = 20;
 2432+ $BackgroundColors{"canvas"} = "gray(0.7)";
 2433+ $Legend{"orientation"} = "ver";
 2434+ $Legend{"left"} = $PlotArea{"left"} + 10;
 2435+ $Legend{"top"} = $PlotArea{"bottom"} + 100;
23292436 &StoreColor("canvas", &EncodeInput("gray(0.7)"), "");
23302437 &StoreColor("grid1", &EncodeInput("gray(0.4)"), "");
23312438 &StoreColor("grid2", &EncodeInput("gray(0.2)"), "");
23322439 push @PresetList, "ImageSize|=|height|auto";
23332440 push @PresetList, "ImageSize|+|barincrement|20";
2334 - push @PresetList, "PlotArea|+|left|" . @PlotArea{"left"};
2335 - push @PresetList, "PlotArea|+|right|" . @PlotArea{"right"};
2336 - push @PresetList, "PlotArea|+|top|" . @PlotArea{"top"};
2337 - push @PresetList, "PlotArea|+|bottom|" . @PlotArea{"bottom"};
 2441+ push @PresetList, "PlotArea|+|left|" . $PlotArea{"left"};
 2442+ push @PresetList, "PlotArea|+|right|" . $PlotArea{"right"};
 2443+ push @PresetList, "PlotArea|+|top|" . $PlotArea{"top"};
 2444+ push @PresetList, "PlotArea|+|bottom|" . $PlotArea{"bottom"};
23382445 push @PresetList, "PlotArea|-|width";
23392446 push @PresetList, "PlotArea|-|height";
23402447 push @PresetList, "Dateformat|-||yyyy";
2341 - push @PresetList, "TimeAxis|=|format|" . @Axis{"format"};
 2448+ push @PresetList, "TimeAxis|=|format|" . $Axis{"format"};
23422449 push @PresetList, "TimeAxis|=|orientation|horizontal";
23432450 push @PresetList, "ScaleMajor|=|unit|year";
23442451 push @PresetList, "ScaleMajor|+|grid|grid1";
23452452 push @PresetList, "ScaleMinor|=|unit|year";
23462453 push @PresetList, "AlignBars|=||justify";
2347 - push @PresetList, "Legend|+|orientation|" . @Legend{"orientation"};
2348 - push @PresetList, "Legend|+|left|" . @Legend{"left"};
2349 - push @PresetList, "Legend|+|top|" . @Legend{"top"};
 2454+ push @PresetList, "Legend|+|orientation|" . $Legend{"orientation"};
 2455+ push @PresetList, "Legend|+|left|" . $Legend{"left"};
 2456+ push @PresetList, "Legend|+|top|" . $Legend{"top"};
23502457 push @PresetList, "PlotData|+|align|left";
23512458 push @PresetList, "PlotData|+|anchor|from";
23522459 push @PresetList, "PlotData|+|fontsize|M";
@@ -2365,30 +2472,30 @@
23662473
23672474 &CheckPreset(Scale . $scale);
23682475
2369 - @Scales{$scale} = $true;
 2476+ $Scales{$scale} = $true;
23702477
2371 - foreach $attribute (keys %Attributes) {
2372 - my $attrvalue = @Attributes{$attribute};
 2478+ foreach my $attribute (keys %Attributes) {
 2479+ my $attrvalue = $Attributes{$attribute};
23732480
23742481 if ($attribute =~ /Grid/i
23752482 ) # preferred gridcolor instead of grid, grid allowed for compatability
23762483 {
23772484 if ( (!&ColorPredefined($attrvalue))
2378 - && (!defined(@Colors{ lc($attrvalue) })))
 2485+ && (!defined($Colors{ lc($attrvalue) })))
23792486 {
23802487 &Error(
23812488 "Scale attribute '$attribute' invalid. Unknown color '$attrvalue'.\n"
23822489 . " Specify command 'Color' before this command.");
23832490 return;
23842491 }
2385 - @Attributes{ $scale . " grid" } = $attrvalue;
2386 - delete(@Attributes{"grid"});
 2492+ $Attributes{ $scale . " grid" } = $attrvalue;
 2493+ delete($Attributes{"grid"});
23872494 }
23882495 elsif ($attribute =~ /Text/i) {
23892496 $attrvalue =~ s/\~/\\n/g;
23902497 $attrvalue =~ s/^\"//g;
23912498 $attrvalue =~ s/\"$//g;
2392 - @Attributes{ $scale . " stubs" } = $attrvalue;
 2499+ $Attributes{ $scale . " stubs" } = $attrvalue;
23932500 }
23942501 elsif ($attribute =~ /Unit/i) {
23952502 if ($DateFormat eq "yyyy") {
@@ -2408,8 +2515,8 @@
24092516 }
24102517 }
24112518 $attrvalue =~ s/s$//;
2412 - @Attributes{ $scale . " unit" } = $attrvalue;
2413 - delete(@Attributes{"unit"});
 2519+ $Attributes{ $scale . " unit" } = $attrvalue;
 2520+ delete($Attributes{"unit"});
24142521 }
24152522 elsif ($attribute =~ /Increment/i) {
24162523 if ((!($attrvalue =~ /^\d+$/i)) || ($attrvalue == 0)) {
@@ -2418,8 +2525,8 @@
24192526 );
24202527 return;
24212528 }
2422 - @Attributes{ $scale . " inc" } = $attrvalue;
2423 - delete(@Attributes{"increment"});
 2529+ $Attributes{ $scale . " inc" } = $attrvalue;
 2530+ delete($Attributes{"increment"});
24242531 }
24252532 elsif ($attribute =~ /Start/i) {
24262533 if (!(defined($DateFormat))) {
@@ -2462,20 +2569,21 @@
24632570 return;
24642571 }
24652572
2466 - @Attributes{ $scale . " start" } = $attrvalue;
2467 - delete(@Attributes{"start"});
 2573+ $Attributes{ $scale . " start" } = $attrvalue;
 2574+ delete($Attributes{"start"});
24682575 }
24692576 if ($DateFormat eq "yyyy") {
2470 - @Attributes{ $scale . " unit" } = "year";
 2577+ $Attributes{ $scale . " unit" } = "year";
24712578 }
24722579 }
24732580
2474 - foreach $attribute (keys %Attributes) {
2475 - @Scales{$attribute} = @Attributes{$attribute};
 2581+ foreach my $attribute (keys %Attributes) {
 2582+ $Scales{$attribute} = $Attributes{$attribute};
24762583 }
24772584 }
24782585
24792586 sub ParseTextData {
 2587+ my ($posx, $posy);
24802588 &GetData;
24812589 if ($NoData) {
24822590 &Error(
@@ -2500,23 +2608,24 @@
25012609 $link = "";
25022610 $hint = "";
25032611
2504 - if (defined(@TextDefs{"tabs"})) { $tabs = @TextDefs{"tabs"}; }
2505 - if (defined(@TextDefs{"fontsize"})) {
2506 - $fontsize = @TextDefs{"fontsize"};
 2612+ if (defined($TextDefs{"tabs"})) { $tabs = $TextDefs{"tabs"}; }
 2613+ if (defined($TextDefs{"fontsize"})) {
 2614+ $fontsize = $TextDefs{"fontsize"};
25072615 }
2508 - if (defined(@TextDefs{"lineheight"})) {
2509 - $lineheight = @TextDefs{"lineheight"};
 2616+ if (defined($TextDefs{"lineheight"})) {
 2617+ $lineheight = $TextDefs{"lineheight"};
25102618 }
2511 - if (defined(@TextDefs{"textcolor"})) {
2512 - $textcolor = @TextDefs{"textcolor"};
 2619+ if (defined($TextDefs{"textcolor"})) {
 2620+ $textcolor = $TextDefs{"textcolor"};
25132621 }
25142622
 2623+ warn "data: $data";
25152624 my $data2 = $data;
25162625 ($data2, $text) = &ExtractText($data2);
25172626 @Attributes = split(" ", $data2);
25182627
2519 - foreach $attribute (keys %Attributes) {
2520 - my $attrvalue = @Attributes{$attribute};
 2628+ foreach my $attribute (keys %Attributes) {
 2629+ my $attrvalue = $Attributes{$attribute};
25212630
25222631 if ($attribute =~ /^FontSize$/i) {
25232632 if ( ($attrvalue !~ /\d+(?:\.\d)?/)
@@ -2569,7 +2678,7 @@
25702679 }
25712680 elsif ($attribute =~ /^(?:Color|TextColor)$/i) {
25722681 if (!&ColorPredefined($attrvalue)) {
2573 - if (!defined(@Colors{ lc($attrvalue) })) {
 2682+ if (!defined($Colors{ lc($attrvalue) })) {
25742683 &Error(
25752684 "TextData invalid. Attribute '$attribute' contains unknown color '$attrvalue'.\n"
25762685 . " Specify command 'Color' before this command."
@@ -2578,8 +2687,8 @@
25792688 next TextData;
25802689 }
25812690 }
2582 - if (defined(@Colors{ lc($attrvalue) })) {
2583 - $textcolor = @Colors{ lc($attrvalue) };
 2691+ if (defined($Colors{ lc($attrvalue) })) {
 2692+ $textcolor = $Colors{ lc($attrvalue) };
25842693 }
25852694 else { $textcolor = lc($attrvalue); }
25862695 }
@@ -2620,12 +2729,12 @@
26212730 if ($textcolor eq "") { $textcolor = "black"; }
26222731
26232732 if ($pos eq "") {
2624 - $pos = @TextDefs{"pos"};
 2733+ $pos = $TextDefs{"pos"};
26252734 ($posx, $posy) = split(",", $pos);
26262735 $posy -= $lineheight;
26272736 if ($posy < 0) { $posy = 0; }
26282737 $pos = "$posx,$posy";
2629 - @TextDefs{"pos"} = $pos;
 2738+ $TextDefs{"pos"} = $pos;
26302739 }
26312740
26322741 # if ($link ne "")
@@ -2633,11 +2742,11 @@
26342743
26352744 if ($text eq "") # upd defaults
26362745 {
2637 - if ($pos ne "") { @TextDefs{"pos"} = $pos; }
2638 - if ($tabs ne "") { @TextDefs{"tabs"} = $tabs; }
2639 - if ($fontsize ne "") { @TextDefs{"fontsize"} = $fontsize; }
2640 - if ($textcolor ne "") { @TextDefs{"textcolor"} = $textcolor; }
2641 - if ($lineheight ne "") { @TextDefs{"lineheight"} = $lineheight; }
 2746+ if ($pos ne "") { $TextDefs{"pos"} = $pos; }
 2747+ if ($tabs ne "") { $TextDefs{"tabs"} = $tabs; }
 2748+ if ($fontsize ne "") { $TextDefs{"fontsize"} = $fontsize; }
 2749+ if ($textcolor ne "") { $TextDefs{"textcolor"} = $textcolor; }
 2750+ if ($lineheight ne "") { $TextDefs{"lineheight"} = $lineheight; }
26422751 &GetData;
26432752 next TextData;
26442753 }
@@ -2663,7 +2772,7 @@
26642773
26652774 if (defined($tabs) && ($tabs ne "")) {
26662775 $tabs =~ s/^\s*$hBrO (.*) $hBrC\s*$/$1/x;
2667 - @Tabs = split(",", $tabs);
 2776+ my @Tabs = split(",", $tabs);
26682777 foreach $tab (@Tabs) {
26692778 $tab =~ s/\s* (.*) \s*$/$1/x;
26702779 if (!($tab =~ /\d+\-(?:center|left|right)$/)) {
@@ -2703,7 +2812,7 @@
27042813 &CheckPreset("TimeAxis");
27052814
27062815 foreach $attribute (keys %Attributes) {
2707 - my $attrvalue = @Attributes{$attribute};
 2816+ my $attrvalue = $Attributes{$attribute};
27082817
27092818 if ($attribute =~ /Format/i) {
27102819 if ($attrvalue =~ /^yy$/i) {
@@ -2741,32 +2850,32 @@
27422851 return;
27432852 }
27442853
2745 - @Attributes{"order"} = lc($attrvalue);
 2854+ $Attributes{"order"} = lc($attrvalue);
27462855 }
27472856
27482857 elsif ($attribute =~ /Orientation/i) {
27492858 if ($attrvalue =~ /^hor(?:izontal)?$/i) {
2750 - @Attributes{"time"} = "x";
 2859+ $Attributes{"time"} = "x";
27512860 }
27522861 elsif ($attrvalue =~ /^ver(?:tical)?$/i) {
2753 - @Attributes{"time"} = "y";
 2862+ $Attributes{"time"} = "y";
27542863 }
27552864 else {
27562865 &Error( "TimeAxis attribute '$attribute' invalid.\n"
27572866 . "Specify hor[izontal] or ver[tical]");
27582867 return;
27592868 }
2760 - delete(@Attributes{"orientation"});
 2869+ delete($Attributes{"orientation"});
27612870 }
27622871 }
27632872
2764 - if (!defined(@Attributes{"format"})) { @Attributes{"format"} = "yyyy"; }
 2873+ if (!defined($Attributes{"format"})) { $Attributes{"format"} = "yyyy"; }
27652874
27662875 %Axis = %Attributes;
27672876 }
27682877
27692878 sub ParseUnknownCommand {
2770 - $name = $Command;
 2879+ my $name = $Command;
27712880 $name =~ s/[^a-zA-Z].*$//;
27722881 &Error("Command '$name' unknown.");
27732882 }
@@ -2778,25 +2887,25 @@
27792888 }
27802889
27812890 sub DetectMissingCommands {
2782 - if (!defined(%Image)) {
 2891+ if (!%Image) {
27832892 &Error2("Command ImageSize missing or invalid");
27842893 }
2785 - if (!defined(%PlotArea)) {
 2894+ if (!%PlotArea) {
27862895 &Error2("Command PlotArea missing or invalid");
27872896 }
2788 - if (!defined($DateFormat)) {
 2897+ if (!$DateFormat) {
27892898 &Error2("Command DateFormat missing or invalid");
27902899 }
2791 - if (!defined(@Axis{"time"})) {
 2900+ if (!$Axis{"time"}) {
27922901 &Error2("Command TimeAxis missing or invalid");
27932902 }
27942903
2795 - if ((@Image{"width"} =~ /auto/i) && (@Axis{"time"} =~ /x/i)) {
 2904+ if (($Image{"width"} =~ /auto/i) && ($Axis{"time"} =~ /x/i)) {
27962905 &Error2(
27972906 "ImageSize value 'width:auto' only allowed with TimeAxis value 'orientation:vertical'"
27982907 );
27992908 }
2800 - if ((@Image{"height"} =~ /auto/i) && (@Axis{"time"} =~ /y/i)) {
 2909+ if (($Image{"height"} =~ /auto/i) && ($Axis{"time"} =~ /y/i)) {
28012910 &Error2(
28022911 "ImageSize value 'height:auto' only allowed with TimeAxis value 'orientation:horizontal'"
28032912 );
@@ -2824,9 +2933,9 @@
28252934 sub ValidateAndNormalizeDimensions {
28262935 my ($val, $dim);
28272936
2828 - if (@Image{"width"} =~ /auto/i) {
 2937+ if ($Image{"width"} =~ /auto/i) {
28292938 foreach $attribute ("width", "left", "right") {
2830 - if (@PlotArea{$attribute} =~ /\%/) {
 2939+ if ($PlotArea{$attribute} =~ /\%/) {
28312940 &Error2( "You specified 'ImageSize = width:auto'.\n"
28322941 . " This implies absolute values in PlotArea attributes 'left', 'right' and/or 'width' (no \%).\n"
28332942 );
@@ -2834,9 +2943,9 @@
28352944 }
28362945 }
28372946
2838 - if ( (@PlotArea{"width"} ne "")
2839 - || (@PlotArea{"left"} eq "")
2840 - || (@PlotArea{"right"} eq ""))
 2947+ if ( ($PlotArea{"width"} ne "")
 2948+ || ($PlotArea{"left"} eq "")
 2949+ || ($PlotArea{"right"} eq ""))
28412950 {
28422951 &Error2( "You specified 'ImageSize = width:auto'.\n"
28432952 . " This implies 'PlotArea = width:auto'.\n"
@@ -2846,9 +2955,9 @@
28472956 }
28482957 }
28492958
2850 - if (@Image{"height"} =~ /auto/i) {
 2959+ if ($Image{"height"} =~ /auto/i) {
28512960 foreach $attribute ("height", "top", "bottom") {
2852 - if (@PlotArea{$attribute} =~ /\%/) {
 2961+ if ($PlotArea{$attribute} =~ /\%/) {
28532962 &Error2( "You specified 'ImageSize = height:auto'.\n"
28542963 . " This implies absolute values in PlotArea attributes 'top', 'bottom' and/or 'height' (no \%).\n"
28552964 );
@@ -2856,9 +2965,9 @@
28572966 }
28582967 }
28592968
2860 - if ( (@PlotArea{"height"} ne "")
2861 - || (@PlotArea{"top"} eq "")
2862 - || (@PlotArea{"bottom"} eq ""))
 2969+ if ( ($PlotArea{"height"} ne "")
 2970+ || ($PlotArea{"top"} eq "")
 2971+ || ($PlotArea{"bottom"} eq ""))
28632972 {
28642973 &Error2( "You specified 'ImageSize = height:auto'.\n"
28652974 . " This implies 'PlotArea = height:auto'.\n"
@@ -2868,39 +2977,39 @@
28692978 }
28702979 }
28712980
2872 - @Image{"width"} = &Normalize(@Image{"width"});
2873 - @Image{"height"} = &Normalize(@Image{"height"});
2874 - @Image{"barinc"} = &Normalize(@Image{"barinc"});
2875 - @PlotArea{"width"} = &Normalize(@PlotArea{"width"}, @Image{"width"});
2876 - @PlotArea{"height"} = &Normalize(@PlotArea{"height"}, @Image{"height"});
2877 - @PlotArea{"left"} = &Normalize(@PlotArea{"left"}, @Image{"width"});
2878 - @PlotArea{"right"} = &Normalize(@PlotArea{"right"}, @Image{"width"});
2879 - @PlotArea{"bottom"} = &Normalize(@PlotArea{"bottom"}, @Image{"height"});
2880 - @PlotArea{"top"} = &Normalize(@PlotArea{"top"}, @Image{"height"});
 2981+ $Image{"width"} = &Normalize($Image{"width"});
 2982+ $Image{"height"} = &Normalize($Image{"height"});
 2983+ $Image{"barinc"} = &Normalize($Image{"barinc"});
 2984+ $PlotArea{"width"} = &Normalize($PlotArea{"width"}, $Image{"width"});
 2985+ $PlotArea{"height"} = &Normalize($PlotArea{"height"}, $Image{"height"});
 2986+ $PlotArea{"left"} = &Normalize($PlotArea{"left"}, $Image{"width"});
 2987+ $PlotArea{"right"} = &Normalize($PlotArea{"right"}, $Image{"width"});
 2988+ $PlotArea{"bottom"} = &Normalize($PlotArea{"bottom"}, $Image{"height"});
 2989+ $PlotArea{"top"} = &Normalize($PlotArea{"top"}, $Image{"height"});
28812990
2882 - if (@Image{"width"} =~ /auto/i) {
2883 - @PlotArea{"width"} = $#Bars * @Image{"barinc"};
2884 - @Image{"width"} =
2885 - @PlotArea{"left"} + @PlotArea{"width"} + @PlotArea{"right"};
 2991+ if ($Image{"width"} =~ /auto/i) {
 2992+ $PlotArea{"width"} = $#Bars * $Image{"barinc"};
 2993+ $Image{"width"} =
 2994+ $PlotArea{"left"} + $PlotArea{"width"} + $PlotArea{"right"};
28862995 }
28872996
2888 - elsif (@Image{"height"} =~ /auto/i) {
2889 - @PlotArea{"height"} = $#Bars * @Image{"barinc"};
2890 - @Image{"height"} =
2891 - @PlotArea{"top"} + @PlotArea{"height"} + @PlotArea{"bottom"};
 2997+ elsif ($Image{"height"} =~ /auto/i) {
 2998+ $PlotArea{"height"} = $#Bars * $Image{"barinc"};
 2999+ $Image{"height"} =
 3000+ $PlotArea{"top"} + $PlotArea{"height"} + $PlotArea{"bottom"};
28923001 }
28933002
2894 - if (@PlotArea{"right"} ne "") {
2895 - @PlotArea{"width"} =
2896 - @Image{"width"} - @PlotArea{"left"} - @PlotArea{"right"};
 3003+ if ($PlotArea{"right"} ne "") {
 3004+ $PlotArea{"width"} =
 3005+ $Image{"width"} - $PlotArea{"left"} - $PlotArea{"right"};
28973006 }
28983007
2899 - if (@PlotArea{"top"} ne "") {
2900 - @PlotArea{"height"} =
2901 - @Image{"height"} - @PlotArea{"top"} - @PlotArea{"bottom"};
 3008+ if ($PlotArea{"top"} ne "") {
 3009+ $PlotArea{"height"} =
 3010+ $Image{"height"} - $PlotArea{"top"} - $PlotArea{"bottom"};
29023011 }
29033012
2904 - if ((@Image{"width"} > 16) || (@Image{"height"} > 20)) {
 3013+ if (($Image{"width"} > 16) || ($Image{"height"} > 20)) {
29053014 if (!$bypass) {
29063015 &Error2( "Maximum image size is 1600x2000 pixels = 16x20 inch\n"
29073016 . " Run with option -b (bypass checks) when this is correct.\n"
@@ -2909,62 +3018,62 @@
29103019 }
29113020 }
29123021
2913 - if ((@Image{"width"} < 0.25) || (@Image{"height"} < 0.25)) {
 3022+ if (($Image{"width"} < 0.25) || ($Image{"height"} < 0.25)) {
29143023 &Error2("Minimum image size is 25x25 pixels = 0.25x0.25 inch\n");
29153024 return;
29163025 }
29173026
2918 - if (@PlotArea{"width"} > @Image{"width"}) {
 3027+ if ($PlotArea{"width"} > $Image{"width"}) {
29193028 &Error2("Plot width larger than image width. Please adjust.\n");
29203029 return;
29213030 }
29223031
2923 - if (@PlotArea{"width"} < 0.2) {
 3032+ if ($PlotArea{"width"} < 0.2) {
29243033 &Error2(
29253034 "Plot width less than 20 pixels = 0.2 inch. Please adjust.\n");
29263035 return;
29273036 }
29283037
2929 - if (@PlotArea{"height"} > @Image{"height"}) {
 3038+ if ($PlotArea{"height"} > $Image{"height"}) {
29303039 &Error2("Plot height larger than image height. Please adjust.\n");
29313040 return;
29323041 }
29333042
2934 - if (@PlotArea{"height"} < 0.2) {
 3043+ if ($PlotArea{"height"} < 0.2) {
29353044 &Error2(
29363045 "Plot height less than 20 pixels = 0.2 inch. Please adjust.\n");
29373046 return;
29383047 }
29393048
2940 - if (@PlotArea{"left"} + @PlotArea{"width"} > @Image{"width"}) {
 3049+ if ($PlotArea{"left"} + $PlotArea{"width"} > $Image{"width"}) {
29413050 &Error2(
29423051 "Plot width + margins larger than image width. Please adjust.\n");
29433052 return;
29443053 }
29453054
2946 - # @PlotArea {"left"} = @Image {"width"} - @PlotArea {"width"} ; }
 3055+ # $PlotArea{"left"} = $Image{"width"} - $PlotArea{"width"} ; }
29473056
2948 - if (@PlotArea{"left"} < 0) { @PlotArea{"left"} = 0; }
 3057+ if ($PlotArea{"left"} < 0) { $PlotArea{"left"} = 0; }
29493058
2950 - if (@PlotArea{"bottom"} + @PlotArea{"height"} > @Image{"height"}) {
 3059+ if ($PlotArea{"bottom"} + $PlotArea{"height"} > $Image{"height"}) {
29513060 &Error2(
29523061 "Plot height + margins larger than image height. Please adjust.\n"
29533062 );
29543063 return;
29553064 }
29563065
2957 - # @PlotArea {"bottom"} = @Image {"height"} - @PlotArea {"height"} ; }
 3066+ # $PlotArea{"bottom"} = $Image{"height"} - $PlotArea{"height"} ; }
29583067
2959 - if (@PlotArea{"bottom"} < 0) { @PlotArea{"bottom"} = 0; }
 3068+ if ($PlotArea{"bottom"} < 0) { $PlotArea{"bottom"} = 0; }
29603069
2961 - if ( (defined(@Scales{"Major"}))
2962 - || (defined(@Scales{"Minor"})))
 3070+ if ( (defined($Scales{"Major"}))
 3071+ || (defined($Scales{"Minor"})))
29633072 {
2964 - if (defined(@Scales{"Major"})) { $margin = 0.2; }
 3073+ if (defined($Scales{"Major"})) { $margin = 0.2; }
29653074 else { $margin = 0.05; }
29663075
2967 - if (@Axis{"time"} eq "x") {
2968 - if (@PlotArea{"bottom"} < $margin) {
 3076+ if ($Axis{"time"} eq "x") {
 3077+ if ($PlotArea{"bottom"} < $margin) {
29693078 &Error2(
29703079 "Not enough space below plot area for plotting time axis\n"
29713080 . " Specify 'PlotArea = bottom:x', where x is at least "
@@ -2974,7 +3083,7 @@
29753084 }
29763085 }
29773086 else {
2978 - if (@PlotArea{"left"} < $margin) {
 3087+ if ($PlotArea{"left"} < $margin) {
29793088 &Error2(
29803089 "Not enough space outside plot area for plotting time axis\n"
29813090 . " Specify 'PlotArea = left:x', where x is at least "
@@ -2985,31 +3094,31 @@
29863095 }
29873096 }
29883097
2989 - if (defined(@Legend{"orientation"})) {
2990 - if (defined(@Legend{"left"})) {
2991 - @Legend{"left"} = &Normalize(@Legend{"left"}, @Image{"width"});
 3098+ if (defined($Legend{"orientation"})) {
 3099+ if (defined($Legend{"left"})) {
 3100+ $Legend{"left"} = &Normalize($Legend{"left"}, $Image{"width"});
29923101 }
2993 - if (defined(@Legend{"top"})) {
2994 - @Legend{"top"} = &Normalize(@Legend{"top"}, @Image{"height"});
 3102+ if (defined($Legend{"top"})) {
 3103+ $Legend{"top"} = &Normalize($Legend{"top"}, $Image{"height"});
29953104 }
2996 - if (defined(@Legend{"columnwidth"})) {
2997 - @Legend{"columnwidth"} =
2998 - &Normalize(@Legend{"columnwidth"}, @Image{"width"});
 3105+ if (defined($Legend{"columnwidth"})) {
 3106+ $Legend{"columnwidth"} =
 3107+ &Normalize($Legend{"columnwidth"}, $Image{"width"});
29993108 }
30003109
3001 - if (!defined(@Legend{"columns"})) {
3002 - @Legend{"columns"} = 1;
3003 - if ( (@Legend{"orientation"} =~ /ver/i)
3004 - && (@Legend{"position"} =~ /^(?:top|bottom)$/i))
 3110+ if (!defined($Legend{"columns"})) {
 3111+ $Legend{"columns"} = 1;
 3112+ if ( ($Legend{"orientation"} =~ /ver/i)
 3113+ && ($Legend{"position"} =~ /^(?:top|bottom)$/i))
30053114 {
30063115 if ($#LegendData > 10) {
3007 - @Legend{"columns"} = 3;
 3116+ $Legend{"columns"} = 3;
30083117 &Info2(
30093118 "Legend attribute 'columns' not defined. 3 columns assumed."
30103119 );
30113120 }
30123121 elsif ($#LegendData > 5) {
3013 - @Legend{"columns"} = 2;
 3122+ $Legend{"columns"} = 2;
30143123 &Info2(
30153124 "Legend attribute 'columns' not defined. 2 columns assumed."
30163125 );
@@ -3017,57 +3126,57 @@
30183127 }
30193128 }
30203129
3021 - if (@Legend{"position"} =~ /top/i) {
3022 - if (!defined(@Legend{"left"})) {
3023 - @Legend{"left"} = @PlotArea{"left"};
 3130+ if ($Legend{"position"} =~ /top/i) {
 3131+ if (!defined($Legend{"left"})) {
 3132+ $Legend{"left"} = $PlotArea{"left"};
30243133 }
3025 - if (!defined(@Legend{"top"})) {
3026 - @Legend{"top"} = (@Image{"height"} - 0.2);
 3134+ if (!defined($Legend{"top"})) {
 3135+ $Legend{"top"} = ($Image{"height"} - 0.2);
30273136 }
3028 - if ( (!defined(@Legend{"columnwidth"}))
3029 - && (@Legend{"columns"} > 1))
 3137+ if ( (!defined($Legend{"columnwidth"}))
 3138+ && ($Legend{"columns"} > 1))
30303139 {
3031 - @Legend{"columnwidth"} = sprintf(
 3140+ $Legend{"columnwidth"} = sprintf(
30323141 "%02f",
30333142 (
3034 - (@PlotArea{"left"} + @PlotArea{"width"} - 0.2) /
3035 - @Legend{"columns"}
 3143+ ($PlotArea{"left"} + $PlotArea{"width"} - 0.2) /
 3144+ $Legend{"columns"}
30363145 )
30373146 );
30383147 }
30393148 }
3040 - elsif (@Legend{"position"} =~ /bottom/i) {
3041 - if (!defined(@Legend{"left"})) {
3042 - @Legend{"left"} = @PlotArea{"left"};
 3149+ elsif ($Legend{"position"} =~ /bottom/i) {
 3150+ if (!defined($Legend{"left"})) {
 3151+ $Legend{"left"} = $PlotArea{"left"};
30433152 }
3044 - if (!defined(@Legend{"top"})) {
3045 - @Legend{"top"} = (@PlotArea{"bottom"} - 0.4);
 3153+ if (!defined($Legend{"top"})) {
 3154+ $Legend{"top"} = ($PlotArea{"bottom"} - 0.4);
30463155 }
3047 - if ( (!defined(@Legend{"columnwidth"}))
3048 - && (@Legend{"columns"} > 1))
 3156+ if ( (!defined($Legend{"columnwidth"}))
 3157+ && ($Legend{"columns"} > 1))
30493158 {
3050 - @Legend{"columnwidth"} = sprintf(
 3159+ $Legend{"columnwidth"} = sprintf(
30513160 "%02f",
30523161 (
3053 - (@PlotArea{"left"} + @PlotArea{"width"} - 0.2) /
3054 - @Legend{"columns"}
 3162+ ($PlotArea{"left"} + $PlotArea{"width"} - 0.2) /
 3163+ $Legend{"columns"}
30553164 )
30563165 );
30573166 }
30583167 }
3059 - elsif (@Legend{"position"} =~ /right/i) {
3060 - if (!defined(@Legend{"left"})) {
3061 - @Legend{"left"} =
3062 - (@PlotArea{"left"} + @PlotArea{"width"} + 0.2);
 3168+ elsif ($Legend{"position"} =~ /right/i) {
 3169+ if (!defined($Legend{"left"})) {
 3170+ $Legend{"left"} =
 3171+ ($PlotArea{"left"} + $PlotArea{"width"} + 0.2);
30633172 }
3064 - if (!defined(@Legend{"top"})) {
3065 - @Legend{"top"} =
3066 - (@PlotArea{"bottom"} + @PlotArea{"height"} - 0.2);
 3173+ if (!defined($Legend{"top"})) {
 3174+ $Legend{"top"} =
 3175+ ($PlotArea{"bottom"} + $PlotArea{"height"} - 0.2);
30673176 }
30683177 }
30693178 }
30703179
3071 - if (!defined(@Axis{"order"})) { @Axis{"order"} = "normal"; }
 3180+ if (!defined($Axis{"order"})) { $Axis{"order"} = "normal"; }
30723181 }
30733182
30743183 sub WriteProcAnnotate {
@@ -3110,8 +3219,12 @@
31113220 $text2 = $text;
31123221 $text2 =~ s/\[\[//g;
31133222 $text2 =~ s/\]\]//g;
3114 - if ($text2 =~ /^\s/) { push @PlotTextsPng, " text: \n\\$text2\n\n"; }
3115 - else { push @PlotTextsPng, " text: $text2\n\n"; }
 3223+ if ($text2 =~ /^\s/) {
 3224+ push @PlotTextsPng, " text: \n\\$text2\n\n";
 3225+ }
 3226+ else {
 3227+ push @PlotTextsPng, " text: $text2\n\n";
 3228+ }
31163229
31173230 $text2 = $text;
31183231 if ($link ne "") {
@@ -3138,8 +3251,12 @@
31393252 while (length($text3) < length($text2)) { $text3 .= "x"; }
31403253 }
31413254
3142 - if ($text3 =~ /^\s/) { push @PlotTextsSvg, " text: \n\\$text3\n\n"; }
3143 - else { push @PlotTextsSvg, " text: $text3\n\n"; }
 3255+ if ($text3 =~ /^\s/) {
 3256+ push @PlotTextsSvg, " text: \n\\$text3\n\n";
 3257+ }
 3258+ else {
 3259+ push @PlotTextsSvg, " text: $text3\n\n";
 3260+ }
31443261
31453262 if ($link ne "") {
31463263 $MapPNG = $true;
@@ -3219,21 +3336,21 @@
32203337 my ($link2, $hint2, $tab);
32213338 my $outside = $false;
32223339
3223 - if (@Axis{"order"} =~ /reverse/i) {
3224 - if (@Axis{"time"} eq "y") { $posy =~ s/(.*)(\(s\))/(-$1).$2/xe; }
 3340+ if ($Axis{"order"} =~ /reverse/i) {
 3341+ if ($Axis{"time"} eq "y") { $posy =~ s/(.*)(\(s\))/(-$1).$2/xe; }
32253342 else { $posx =~ s/(.*)(\(s\))/(-$1).$2/xe; }
32263343 }
32273344
32283345 if ($posx !~ /\(s\)/) {
32293346 if ($posx < 0) { $outside = $true; }
3230 - if (@Image{"width"} !~ /auto/i) {
3231 - if ($posx > @Image{"width"} / 100) { $outside = $true; }
 3347+ if ($Image{"width"} !~ /auto/i) {
 3348+ if ($posx > $Image{"width"} / 100) { $outside = $true; }
32323349 }
32333350 }
32343351 if ($posy !~ /\(s\)/) {
32353352 if ($posy < 0) { $outside = $true; }
3236 - if (@Image{"height"} !~ /auto/i) {
3237 - if ($posy > @Image{"height"} / 100) { $outside = $true; }
 3353+ if ($Image{"height"} !~ /auto/i) {
 3354+ if ($posy > $Image{"height"} / 100) { $outside = $true; }
32383355 }
32393356 }
32403357 if ($outside) {
@@ -3247,7 +3364,9 @@
32483365 }
32493366
32503367 my @Tabs = split(",", $tabs);
3251 - foreach $tab (@Tabs) { $tab =~ s/\s* (.*) \s*$/$1/x; }
 3368+ foreach (@Tabs) {
 3369+ s/\s* (.*) \s*$/$1/x;
 3370+ }
32523371
32533372 $posx0 = $posx;
32543373 my @Text;
@@ -3258,8 +3377,9 @@
32593378 $hint = "";
32603379 }
32613380
3262 - my @Text;
3263 - if ($mode eq "^") { @Text = split('\^', $text); }
 3381+ if ($mode eq "^") {
 3382+ @Text = split('\^', $text);
 3383+ }
32643384 elsif ($mode eq "~") {
32653385 @Text = split('\n', $text);
32663386
@@ -3277,9 +3397,11 @@
32783398 }
32793399 }
32803400 }
3281 - else { push @Text, $text; }
 3401+ else {
 3402+ push @Text, $text;
 3403+ }
32823404
3283 - foreach $text (@Text) {
 3405+ foreach $text (@Text) { # XXX $text should be renamed here
32843406 if ($text !~ /^[\n\s]*$/) {
32853407 $link2 = "";
32863408 $hint2 = "";
@@ -3358,10 +3480,10 @@
33593481
33603482 $script = "";
33613483 my ($color);
3362 - if (@Axis{"time"} eq "x") { $AxisBars = "y"; }
 3484+ if ($Axis{"time"} eq "x") { $AxisBars = "y"; }
33633485 else { $AxisBars = "x"; }
33643486
3365 - # if ((@Axis {"time"} eq "y") && ($#Bars > 0))
 3487+ # if (($Axis{"time"} eq "y") && ($#Bars > 0))
33663488 # {
33673489 # undef @BarsTmp ;
33683490 # while ($#Bars >= 0)
@@ -3372,11 +3494,13 @@
33733495 if ($tmpdir ne "") {
33743496 $file_script = $tmpdir . $pathseparator . "EasyTimeline.txt.$$";
33753497 }
3376 - else { $file_script = "EasyTimeline.txt"; }
 3498+ else {
 3499+ $file_script = "EasyTimeline.txt";
 3500+ }
33773501
33783502 print "Ploticus input file = " . $file_script . "\n";
33793503
3380 - # $fmt = "gif" ;
 3504+ # $image_file_fmt = "gif" ;
33813505 open "FILE_OUT", ">", $file_script;
33823506
33833507 #proc settings
@@ -3388,9 +3512,9 @@
33893513 $script .= "#proc page\n";
33903514 $script .= " dopagebox: no\n";
33913515 $script .=
3392 - " pagesize: " . @Image{"width"} . " " . @Image{"height"} . "\n";
3393 - if (defined(@BackgroundColors{"canvas"})) {
3394 - $script .= " backgroundcolor: " . @BackgroundColors{"canvas"} . "\n";
 3516+ " pagesize: " . $Image{"width"} . " " . $Image{"height"} . "\n";
 3517+ if (defined($BackgroundColors{"canvas"})) {
 3518+ $script .= " backgroundcolor: " . $BackgroundColors{"canvas"} . "\n";
33953519 }
33963520 $script .= "\n";
33973521
@@ -3418,7 +3542,7 @@
34193543 # -> 2BU = PU - PC
34203544 # -> U (2B-P) = -PC
34213545 # -> U = -PC/(2B-P)
3422 - # P = @PlotArea {$extent}
 3546+ # P = $PlotArea{$extent}
34233547 # C = c - 1 = $#Bars
34243548 # 2B = $MaxBarWidth
34253549 if (!defined($AlignBars)) {
@@ -3426,17 +3550,17 @@
34273551 $AlignBars = "early";
34283552 }
34293553
3430 - if (@Axis{"time"} eq "x") { $extent = "height"; }
 3554+ if ($Axis{"time"} eq "x") { $extent = "height"; }
34313555 else { $extent = "width"; }
34323556
3433 - if ($MaxBarWidth > @PlotArea{$extent}) {
 3557+ if ($MaxBarWidth > $PlotArea{$extent}) {
34343558 &Error2("Maximum bar width exceeds plotarea " . $extent . ".");
34353559 return;
34363560 }
34373561
3438 - if ($MaxBarWidth == @PlotArea{$extent}) { @PlotArea{$extent} += 0.01; }
 3562+ if ($MaxBarWidth == $PlotArea{$extent}) { $PlotArea{$extent} += 0.01; }
34393563
3440 - if ($MaxBarWidth == @PlotArea{$extent}) {
 3564+ if ($MaxBarWidth == $PlotArea{$extent}) {
34413565 $till = 1;
34423566 $from = 1;
34433567 }
@@ -3444,8 +3568,8 @@
34453569 if ($AlignBars eq "justify") {
34463570 if ($#Bars > 0) {
34473571 $U =
3448 - -(@PlotArea{$extent} * $#Bars) /
3449 - ($MaxBarWidth - @PlotArea{$extent});
 3572+ -($PlotArea{$extent} * $#Bars) /
 3573+ ($MaxBarWidth - $PlotArea{$extent});
34503574 $x = ($U - $#Bars) / 2;
34513575 $from = 1 - $x;
34523576 $till = 1 + $#Bars + $x;
@@ -3453,7 +3577,7 @@
34543578 else # one bar-> "justify" is misnomer here, treat as "center"
34553579 {
34563580
3457 - # $x = ($MaxBarWidth /2) / @PlotArea {$extent} ;
 3581+ # $x = ($MaxBarWidth /2) / $PlotArea{$extent} ;
34583582 # $from = 0.5 - $x ;
34593583 # $till = $from + 1 ;
34603584 $from = 0.5;
@@ -3463,13 +3587,13 @@
34643588 elsif ($AlignBars eq "early") {
34653589 $U = $#Bars + 1;
34663590 if ($U == 0) { $U = 1; }
3467 - $x = (($MaxBarWidth / 2) * $U) / @PlotArea{$extent};
 3591+ $x = (($MaxBarWidth / 2) * $U) / $PlotArea{$extent};
34683592 $from = 1 - $x;
34693593 $till = $from + $U;
34703594 }
34713595 elsif ($AlignBars eq "late") {
34723596 $U = $#Bars + 1;
3473 - $x = (($MaxBarWidth / 2) * $U) / @PlotArea{$extent};
 3597+ $x = (($MaxBarWidth / 2) * $U) / $PlotArea{$extent};
34743598 $till = $U + $x;
34753599 $from = $till - $U;
34763600 }
@@ -3486,30 +3610,30 @@
34873611 $script .= "#proc areadef\n";
34883612 $script .=
34893613 " rectangle: "
3490 - . @PlotArea{"left"} . " "
3491 - . @PlotArea{"bottom"} . " "
3492 - . sprintf("%.2f", @PlotArea{"left"} + @PlotArea{"width"}) . " "
3493 - . sprintf("%.2f", @PlotArea{"bottom"} + @PlotArea{"height"}) . "\n";
 3614+ . $PlotArea{"left"} . " "
 3615+ . $PlotArea{"bottom"} . " "
 3616+ . sprintf("%.2f", $PlotArea{"left"} + $PlotArea{"width"}) . " "
 3617+ . sprintf("%.2f", $PlotArea{"bottom"} + $PlotArea{"height"}) . "\n";
34943618 if (($DateFormat eq "yyyy") || ($DateFormat eq "x.y")) {
3495 - $script .= " " . @Axis{"time"} . "scaletype: linear\n";
 3619+ $script .= " " . $Axis{"time"} . "scaletype: linear\n";
34963620 } # date yyyy
34973621 else {
3498 - $script .= " " . @Axis{"time"} . "scaletype: date $DateFormat\n";
 3622+ $script .= " " . $Axis{"time"} . "scaletype: date $DateFormat\n";
34993623 }
35003624
3501 - if (@Axis{"order"} !~ /reverse/i) {
 3625+ if ($Axis{"order"} !~ /reverse/i) {
35023626 $script .= " "
3503 - . @Axis{"time"}
 3627+ . $Axis{"time"}
35043628 . "range: "
3505 - . @Period{"from"} . " "
3506 - . @Period{"till"} . "\n";
 3629+ . $Period{"from"} . " "
 3630+ . $Period{"till"} . "\n";
35073631 }
35083632 else {
35093633 $script .= " "
3510 - . @Axis{"time"}
 3634+ . $Axis{"time"}
35113635 . "range: "
3512 - . (-@Period{"till"}) . " "
3513 - . (-@Period{"from"}) . "\n";
 3636+ . (-$Period{"till"}) . " "
 3637+ . (-$Period{"from"}) . "\n";
35143638 }
35153639
35163640 $script .= " " . $AxisBars . "scaletype: linear\n";
@@ -3533,15 +3657,15 @@
35343658 $script .= "#proc legendentry\n";
35353659 $script .= " sampletype: color\n";
35363660
3537 - if ((defined(@ColorLabels{$color})) && (@ColorLabels{$color} ne "")) {
3538 - $script .= " label: " . @ColorLabels{$color} . "\n";
 3661+ if ((defined($ColorLabels{$color})) && ($ColorLabels{$color} ne "")) {
 3662+ $script .= " label: " . $ColorLabels{$color} . "\n";
35393663 }
3540 - $script .= " details: " . @Colors{$color} . "\n";
 3664+ $script .= " details: " . $Colors{$color} . "\n";
35413665 $script .= " tag: $color\n";
35423666 $script .= "\n";
35433667 }
35443668
3545 - if (defined(@BackgroundColors{"bars"})) {
 3669+ if (defined($BackgroundColors{"bars"})) {
35463670
35473671 #proc getdata / #proc bars
35483672 $script .= "#proc getdata\n";
@@ -3557,18 +3681,18 @@
35583682 for ($b = 0; $b <= $#Bars; $b++) {
35593683 $script .=
35603684 ($b + 1) . ","
3561 - . @Period{"from"} . ","
3562 - . @Period{"till"} . ","
3563 - . @BackgroundColors{"bars"} . "\n";
 3685+ . $Period{"from"} . ","
 3686+ . $Period{"till"} . ","
 3687+ . $BackgroundColors{"bars"} . "\n";
35643688 }
35653689 $script .= "\n";
35663690
35673691 #proc bars
35683692 $script .= "#proc bars\n";
3569 - $script .= " axis: " . @Axis{"time"} . "\n";
 3693+ $script .= " axis: " . $Axis{"time"} . "\n";
35703694 $script .= " barwidth: $maxwidth\n";
35713695 $script .= " outline: no\n";
3572 - if (@Axis{"time"} eq "x") { $script .= " horizontalbars: yes\n"; }
 3696+ if ($Axis{"time"} eq "x") { $script .= " horizontalbars: yes\n"; }
35733697 $script .= " locfield: 1\n";
35743698 $script .= " segmentfields: 2 3\n";
35753699 $script .= " colorfield: 4\n";
@@ -3580,8 +3704,8 @@
35813705 }
35823706
35833707 #proc axis
3584 - if (defined(@Scales{"Minor grid"})) { &PlotScale("Minor", $true); }
3585 - if (defined(@Scales{"Major grid"})) { &PlotScale("Major", $true); }
 3708+ if (defined($Scales{"Minor grid"})) { &PlotScale("Minor", $true); }
 3709+ if (defined($Scales{"Major grid"})) { &PlotScale("Major", $true); }
35863710
35873711 &PlotLines("back");
35883712
@@ -3594,7 +3718,7 @@
35953719 foreach $entry (@PlotLines) {
35963720 ($bar) = split(",", $entry);
35973721 $bar =~ s/\#.*//;
3598 - $width = @BarWidths{$bar};
 3722+ $width = $BarWidths{$bar};
35993723 $entry = sprintf("%6.3f", $width) . "," . $entry;
36003724 }
36013725
@@ -3626,7 +3750,10 @@
36273751 $scriptPng2 .= " stubs: text\n";
36283752 $scriptSvg2 .= " stubs: text\n";
36293753
3630 - my ($text, $link, $hint);
 3754+ # XXX huh? Yields a warning.
 3755+ my $text;
 3756+ my $link;
 3757+ my $hint;
36313758
36323759 undef(@Bars2);
36333760 foreach $bar (@Bars) {
@@ -3636,10 +3763,10 @@
36373764
36383765 foreach $bar (@Bars2) {
36393766 $hint = "";
3640 - $text = @BarLegend{ lc($bar) };
 3767+ $text = $BarLegend{ lc($bar) };
36413768 if ($text =~ /^\s*$/) { $text = "\\"; }
36423769
3643 - $link = @BarLink{ lc($bar) };
 3770+ $link = $BarLink{ lc($bar) };
36443771 if (!defined($link)) {
36453772 if ($text =~ /\[.*\]/) {
36463773 ($text, $link, $hint) =
@@ -3678,10 +3805,10 @@
36793806 $barcnt = $#Bars + 1;
36803807 foreach $bar (@Bars2) {
36813808 $hint = "";
3682 - $text = @BarLegend{ lc($bar) };
 3809+ $text = $BarLegend{ lc($bar) };
36833810 if ($text =~ /^\s*$/) { $text = "\\"; }
36843811
3685 - $link = @BarLink{ lc($bar) };
 3812+ $link = $BarLink{ lc($bar) };
36863813 if (!defined($link)) {
36873814 if ($text =~ /\[.*\]/) {
36883815 ($text, $link, $hint) =
@@ -3693,10 +3820,10 @@
36943821 $scriptPng3 .= "#proc rect\n";
36953822 $scriptPng3 .=
36963823 " rectangle: 0 $barcnt(s)+0.05 "
3697 - . @PlotArea{"left"}
 3824+ . $PlotArea{"left"}
36983825 . " $barcnt(s)-0.05\n";
36993826 $scriptPng3 .=
3700 - " color: " . @BackgroundColors{"canvas"} . "\n";
 3827+ " color: " . $BackgroundColors{"canvas"} . "\n";
37013828 $scriptPng3 .= " clickmapurl: " . $link . "\n";
37023829 if ((defined($hint)) && ($hint ne "")) {
37033830 $scriptPng3 .= " clickmaplabel: " . $hint . "\n";
@@ -3746,8 +3873,8 @@
37473874 #proc axis
37483875 # repeat without grid to get axis on top of bar
37493876 # needed because axis may overlap bar slightly
3750 - if (defined(@Scales{"Minor"})) { &PlotScale("Minor", $false); }
3751 - if (defined(@Scales{"Major"})) { &PlotScale("Major", $false); }
 3877+ if (defined($Scales{"Minor"})) { &PlotScale("Minor", $false); }
 3878+ if (defined($Scales{"Major"})) { &PlotScale("Major", $false); }
37523879
37533880 #proc drawcommands
37543881 if ($#TextData >= 0) {
@@ -3758,7 +3885,7 @@
37593886 }
37603887
37613888 #proc legend
3762 - if (defined(@Legend{"orientation"})) {
 3889+ if (defined($Legend{"orientation"})) {
37633890 if (($#LegendData < 0) && ($Preset eq "")) {
37643891 &Error2(
37653892 "Command 'Legend' found, but no entries for the legend were specified.\n"
@@ -3769,19 +3896,19 @@
37703897 }
37713898
37723899 $perColumn = 999;
3773 - if (@Legend{"orientation"} =~ /ver/i) {
3774 - if (@Legend{"columns"} > 1) {
 3900+ if ($Legend{"orientation"} =~ /ver/i) {
 3901+ if ($Legend{"columns"} > 1) {
37753902 $perColumn = 0;
3776 - while ((@Legend{"columns"} * $perColumn) < $#LegendData + 1) {
 3903+ while (($Legend{"columns"} * $perColumn) < $#LegendData + 1) {
37773904 $perColumn++;
37783905 }
37793906 }
37803907 }
37813908
3782 - for ($l = 1; $l <= @Legend{"columns"}; $l++) {
 3909+ for ($l = 1; $l <= $Legend{"columns"}; $l++) {
37833910 $script .= "#proc legend\n";
37843911 $script .= " noclear: yes\n";
3785 - if (@Legend{"orientation"} =~ /ver/i) {
 3912+ if ($Legend{"orientation"} =~ /ver/i) {
37863913 $script .= " format: multiline\n";
37873914 }
37883915 else { $script .= " format: singleline\n"; }
@@ -3790,28 +3917,32 @@
37913918 $script .= " textdetails: size=S\n";
37923919 $script .=
37933920 " location: "
3794 - . (@Legend{"left"} + 0.2) . " "
3795 - . @Legend{"top"} . "\n";
 3921+ . ($Legend{"left"} + 0.2) . " "
 3922+ . $Legend{"top"} . "\n";
37963923 $script .= " specifyorder:\n";
37973924 for ($l2 = 1; $l2 <= $perColumn; $l2++) {
37983925 $category = shift(@LegendData);
37993926 if (defined($category)) { $script .= "$category\n"; }
38003927 }
38013928 $script .= "\n";
3802 - @Legend{"left"} += @Legend{"columnwidth"};
 3929+ $Legend{"left"} += $Legend{"columnwidth"};
38033930 }
38043931 }
38053932
38063933 $script .= "#endproc\n";
38073934
38083935 print "\nGenerating output:\n";
3809 - if ($plcommand ne "") { $pl = $plcommand; }
 3936+ if ($ploticus_command ne "") {
 3937+ $pl = $ploticus_command;
 3938+ }
38103939 else {
38113940 $pl = "pl.exe";
38123941 if ($env eq "Linux") { $pl = "pl"; }
38133942 }
38143943
3815 - print "Using ploticus command \"" . $pl . "\" (" . $plcommand . ")\n";
 3944+ print "Using ploticus command \""
 3945+ . $pl . "\" ("
 3946+ . $ploticus_command . ")\n";
38163947
38173948 $script_save = $script;
38183949
@@ -3884,15 +4015,15 @@
38854016 $map = '';
38864017 }
38874018
3888 - # $crop = "-crop 0,0," + @ImageSize {"width"} . "," . @ImageSize {"height"} ;
 4019+ # $crop = "-crop 0,0," + $ImageSize{"width"} . "," . $ImageSize{"height"} ;
38894020 print "Running Ploticus to generate bitmap\n";
38904021
3891 - # $cmd = "$pl $map -" . $fmt . " -o $file_bitmap $file_script -tightcrop" ; # -v $file_bitmap" ;
3892 - # $cmd = "$pl $map -" . $fmt . " -o $file_bitmap $file_script -tightcrop -diagfile $file_pl_info -errfile $file_pl_err" ;
 4022+ # $cmd = "$pl $map -" . $image_file_fmt . " -o $file_bitmap $file_script -tightcrop" ; # -v $file_bitmap" ;
 4023+ # $cmd = "$pl $map -" . $image_file_fmt . " -o $file_bitmap $file_script -tightcrop -diagfile $file_pl_info -errfile $file_pl_err" ;
38934024 $cmd =
38944025 EscapeShellArg($pl)
38954026 . " $map -"
3896 - . $fmt . " -o "
 4027+ . $image_file_fmt . " -o "
38974028 . EscapeShellArg($file_bitmap) . " "
38984029 . EscapeShellArg($file_script)
38994030 . " -tightcrop -font "
@@ -3908,7 +4039,7 @@
39094040 }
39104041
39114042 # not for Wikipedia, only for offline use:
3912 - if ((-e $file_bitmap) && ($fmt eq "gif")) {
 4043+ if ((-e $file_bitmap) && ($image_file_fmt eq "gif")) {
39134044 print "Running nconvert to convert gif image to png format\n\n";
39144045 print
39154046 "---------------------------------------------------------------------------\n";
@@ -3938,9 +4069,9 @@
39394070 $shift =~ s/^.*\&\&([^\"]*)\".*$/$1/;
39404071 $line =~ s/\&\&[^\"]*//;
39414072 (@updcoords) = split(",", $coords);
3942 - $maplength = @updcoords[2] - @updcoords[0];
3943 - @updcoords[0] = @updcoords[0] - 2 * ($maplength - 25);
3944 - @updcoords[2] = @updcoords[0] + $maplength;
 4073+ $maplength = $updcoords[2] - $updcoords[0];
 4074+ $updcoords[0] = $updcoords[0] - 2 * ($maplength - 25);
 4075+ $updcoords[2] = $updcoords[0] + $maplength;
39454076 $coordsnew = join(",", @updcoords);
39464077 $line =~ s/$coords/$coordsnew/;
39474078 push @map2, $line . "\n";
@@ -3959,9 +4090,9 @@
39604091 close "FILE_IN";
39614092
39624093 foreach $line (@svg) {
3963 - $line =~ s/\{\{(\d+)\}\}x+/@textsSVG[$1]/gxe;
 4094+ $line =~ s/\{\{(\d+)\}\}x+/$textsSVG[$1]/gxe;
39644095 $line =~
3965 - s/\[(\d+)\[ (.*?) \]\d+\]/'<a style="fill:blue;" xlink:href="' . @linksSVG[$1] . '">' . $2 . '<\/a>'/gxe;
 4096+ s/\[(\d+)\[ (.*?) \]\d+\]/'<a style="fill:blue;" xlink:href="' . $linksSVG[$1] . '">' . $2 . '<\/a>'/gxe;
39664097 }
39674098
39684099 open "FILE_OUT", ">", $file_vector;
@@ -3978,8 +4109,8 @@
39794110 close "FILE_IN";
39804111 }
39814112 print "Generating html test file\n";
3982 - $width = sprintf("%.0f", @Image{"width"} * 100);
3983 - $height = sprintf("%.0f", @Image{"height"} * 100);
 4113+ $width = sprintf("%.0f", $Image{"width"} * 100);
 4114+ $height = sprintf("%.0f", $Image{"height"} * 100);
39844115 $html = <<__HTML__ ;
39854116
39864117 <html>
@@ -4051,10 +4182,10 @@
40524183
40534184 my $barcnt = 0;
40544185 for ($b = 0; $b <= $#Bars; $b++) {
4055 - if (lc(@Bars[$b]) eq lc($bar)) { $barcnt = ($b + 1); last; }
 4186+ if (lc($Bars[$b]) eq lc($bar)) { $barcnt = ($b + 1); last; }
40564187 }
40574188
4058 - if (@Axis{"time"} eq "x") {
 4189+ if ($Axis{"time"} eq "x") {
40594190 $xpos = "$at(s)";
40604191 $ypos = "[$barcnt](s)";
40614192 }
@@ -4100,12 +4231,12 @@
41014232 next;
41024233 }
41034234 for ($b = 0; $b <= $#Bars; $b++) {
4104 - if (lc(@Bars[$b]) eq lc($bar)) {
 4235+ if (lc($Bars[$b]) eq lc($bar)) {
41054236 $bar = ($#Bars - ($b - 1));
41064237 last;
41074238 }
41084239 }
4109 - if (@Axis{"order"} !~ /reverse/i) {
 4240+ if ($Axis{"order"} !~ /reverse/i) {
41104241 $entry = "$bar,$from,$till,$color,$link,$hint,\n";
41114242 }
41124243 else {
@@ -4121,21 +4252,21 @@
41224253
41234254 #proc bars
41244255 $script .= "#proc bars\n";
4125 - $script .= " axis: " . @Axis{"time"} . "\n";
 4256+ $script .= " axis: " . $Axis{"time"} . "\n";
41264257 $script .= " barwidth: $maxwidth\n";
41274258 $script .= " outline: no\n";
41284259
41294260 # $script .= " thinbarline: width=5\n" ;
4130 - if (@Axis{"time"} eq "x") { $script .= " horizontalbars: yes\n"; }
 4261+ if ($Axis{"time"} eq "x") { $script .= " horizontalbars: yes\n"; }
41314262 $script .= " locfield: 1\n";
41324263 $script .= " segmentfields: 2 3\n";
41334264 $script .= " colorfield: 4\n";
41344265
41354266 # $script .= " outline: width=1\n" ;
41364267 # $script .= " barwidthfield: 5\n" ;
4137 - # if (@fields [4] ne "")
 4268+ # if ($fields[4] ne "")
41384269 # { $script .= " clickmapurl: " . &LinkToUrl ($text) . "\n" ; }
4139 - # if (@fields [5] ne "")
 4270+ # if ($fields[5] ne "")
41404271 # { $script .= " clickmaplabel: $text\n" ; }
41414272 $script .= " clickmapurl: \@\@5\n";
41424273 $script .= " clickmaplabel: \@\@6\n";
@@ -4161,24 +4292,24 @@
41624293
41634294 # if (! $grid) # redefine area, scale linear for time axis, showl whole years always, Ploticus bug
41644295 # {
4165 - # $from = @Period {"from"} ;
4166 - # $till = @Period {"till"} ;
4167 - $from = &DateToFloat(@Period{"from"});
4168 - $till = &DateToFloat(@Period{"till"});
 4296+ # $from = $Period{"from"} ;
 4297+ # $till = $Period{"till"} ;
 4298+ $from = &DateToFloat($Period{"from"});
 4299+ $till = &DateToFloat($Period{"till"});
41694300
41704301 # $from =~ s/.*\///g ; # delete dd mm if present
41714302 # $till =~ s/.*\///g ;
41724303 #proc areadef
41734304 $script .= "#proc areadef\n";
41744305 $script .= " #clone: A\n";
4175 - $script .= " " . @Axis{"time"} . "scaletype: linear\n"; # date yyyy
 4306+ $script .= " " . $Axis{"time"} . "scaletype: linear\n"; # date yyyy
41764307
4177 - if (@Axis{"order"} !~ /reverse/i) {
4178 - $script .= " " . @Axis{"time"} . "range: $from $till\n";
 4308+ if ($Axis{"order"} !~ /reverse/i) {
 4309+ $script .= " " . $Axis{"time"} . "range: $from $till\n";
41794310 }
41804311 else {
41814312 $script .= " "
4182 - . @Axis{"time"}
 4313+ . $Axis{"time"}
41834314 . "range: "
41844315 . (-$till) . " "
41854316 . (-$from) . "\n";
@@ -4188,45 +4319,45 @@
41894320
41904321 # }
41914322
4192 - $script .= "#proc " . @Axis{"time"} . "axis\n";
 4323+ $script .= "#proc " . $Axis{"time"} . "axis\n";
41934324
41944325 if (($scale eq "Major") && (!$grid)) {
41954326
4196 - # $script .= " stubs: incremental " . @Scales {"Major inc"} . " " . @Scales {"Major unit"} . "\n" ;
 4327+ # $script .= " stubs: incremental " . $Scales{"Major inc"} . " " . $Scales{"Major unit"} . "\n" ;
41974328 # if ($DateFormat =~ /\//)
4198 - # { $script .= " stubformat: " . @Axis {"format"} . "\n" ; }
 4329+ # { $script .= " stubformat: " . $Axis{"format"} . "\n" ; }
41994330 # temp always show whole years (Ploticus autorange bug)
4200 - if (@Scales{"Major stubs"} eq "") # ($DateFormat !~ /\//)
 4331+ if ($Scales{"Major stubs"} eq "") # ($DateFormat !~ /\//)
42014332 {
4202 - $script .= " stubs: incremental " . @Scales{"Major inc"} . "\n";
 4333+ $script .= " stubs: incremental " . $Scales{"Major inc"} . "\n";
42034334 }
4204 - else { $script .= " stubs: list " . @Scales{"Major stubs"} . "\n"; }
 4335+ else { $script .= " stubs: list " . $Scales{"Major stubs"} . "\n"; }
42054336 }
42064337 else { $script .= " stubs: none\n"; }
42074338
42084339 if ($DateFormat !~ /\//)
42094340
4210 - # { $script .= " ticincrement: " . @Scales {"$scale inc"} . " " . @Scales {"$scale unit"} . "\n" ; }
 4341+ # { $script .= " ticincrement: " . $Scales{"$scale inc"} . " " . $Scales{"$scale unit"} . "\n" ; }
42114342 {
4212 - $script .= " ticincrement: " . @Scales{"$scale inc"} . "\n";
 4343+ $script .= " ticincrement: " . $Scales{"$scale inc"} . "\n";
42134344 }
42144345 else {
42154346 my $unit = 1;
4216 - if (@Scales{"$scale unit"} =~ /month/i) { $unit = 1 / 12; }
4217 - if (@Scales{"$scale unit"} =~ /day/i) { $unit = 1 / 365; }
4218 - $script .= " ticincrement: " . @Scales{"$scale inc"} . " $unit\n";
 4347+ if ($Scales{"$scale unit"} =~ /month/i) { $unit = 1 / 12; }
 4348+ if ($Scales{"$scale unit"} =~ /day/i) { $unit = 1 / 365; }
 4349+ $script .= " ticincrement: " . $Scales{"$scale inc"} . " $unit\n";
42194350 }
42204351
4221 - if (defined(@Scales{"$scale start"})) {
4222 - $start = @Scales{"$scale start"};
 4352+ if (defined($Scales{"$scale start"})) {
 4353+ $start = $Scales{"$scale start"};
42234354
42244355 # $start =~ s/.*\///g ; # delete dd mm if present
42254356 $start = &DateToFloat($start);
4226 - if (@Axis{"order"} =~ /reverse/i) {
 4357+ if ($Axis{"order"} =~ /reverse/i) {
42274358 $loop = 0;
42284359 $start = -$start;
4229 - while ($start - @Scales{"$scale inc"} >= -@Period{"till"}) {
4230 - $start -= @Scales{"$scale inc"};
 4360+ while ($start - $Scales{"$scale inc"} >= -$Period{"till"}) {
 4361+ $start -= $Scales{"$scale inc"};
42314362 if (++$loop > 1000) { last; } # precaution
42324363 }
42334364 }
@@ -4235,10 +4366,10 @@
42364367
42374368 if ($scale eq "Major") {
42384369 $script .= " ticlen: 0.05\n";
4239 - if (@Axis{"time"} eq "y") {
 4370+ if ($Axis{"time"} eq "y") {
42404371 $script .= " stubdetails: adjust=0.05,0\n";
42414372 }
4242 - if (@Axis{"order"} =~ /reverse/i) {
 4373+ if ($Axis{"order"} =~ /reverse/i) {
42434374 $script .= " signreverse: yes\n";
42444375 }
42454376 }
@@ -4246,9 +4377,9 @@
42474378
42484379 # $script .= " location: 4\n" ; test
42494380
4250 - $color .= @Scales{"$scale grid"};
 4381+ $color .= $Scales{"$scale grid"};
42514382
4252 - if (defined(@Colors{$color})) { $color = @Colors{$color}; }
 4383+ if (defined($Colors{$color})) { $color = $Colors{$color}; }
42534384
42544385 if ($grid) { $script .= " grid: color=$color\n"; }
42554386
@@ -4291,50 +4422,50 @@
42924423
42934424 if ($mode == 1) # draw perpendicular to time axis
42944425 {
4295 - if (@Axis{"order"} =~ /reverse/i) { $at = -$at; }
 4426+ if ($Axis{"order"} =~ /reverse/i) { $at = -$at; }
42964427
4297 - if (@Axis{"time"} eq "x") {
4298 - if ($from eq "") { $from = @PlotArea{"bottom"} }
 4428+ if ($Axis{"time"} eq "x") {
 4429+ if ($from eq "") { $from = $PlotArea{"bottom"} }
42994430 if ($till eq "") {
4300 - $till = @PlotArea{"bottom"} + @PlotArea{"height"};
 4431+ $till = $PlotArea{"bottom"} + $PlotArea{"height"};
43014432 }
43024433 $from += ($width / 200)
43034434 ; # compensate for overstrechting of thick lines
43044435 $till -= ($width / 200);
4305 - if ($from > @Image{"height"}) { $from = @Image{"height"}; }
4306 - if ($till > @Image{"height"}) { $till = @Image{"height"}; }
 4436+ if ($from > $Image{"height"}) { $from = $Image{"height"}; }
 4437+ if ($till > $Image{"height"}) { $till = $Image{"height"}; }
43074438 $script .= " points: $at(s) $from $at(s) $till\n";
43084439 }
43094440 else {
4310 - if ($from eq "") { $from = @PlotArea{"left"} }
 4441+ if ($from eq "") { $from = $PlotArea{"left"} }
43114442 if ($till eq "") {
4312 - $till = @PlotArea{"left"} + @PlotArea{"width"};
 4443+ $till = $PlotArea{"left"} + $PlotArea{"width"};
43134444 }
43144445 $from += ($width / 200);
43154446 $till -= ($width / 200);
4316 - if ($from > @Image{"width"}) { $from = @Image{"width"}; }
4317 - if ($till > @Image{"width"}) { $till = @Image{"width"}; }
 4447+ if ($from > $Image{"width"}) { $from = $Image{"width"}; }
 4448+ if ($till > $Image{"width"}) { $till = $Image{"width"}; }
43184449 $script .= " points: $from $at(s) $till $at(s)\n";
43194450 }
43204451 }
43214452
43224453 if ($mode == 2) # draw parralel to time axis
43234454 {
4324 - if (@Axis{"order"} =~ /reverse/i) {
 4455+ if ($Axis{"order"} =~ /reverse/i) {
43254456 $from = -$from;
43264457 $till = -$till;
43274458 }
43284459
43294460 $from .= "(s)+" . ($width / 200);
43304461 $till .= "(s)-" . ($width / 200);
4331 - if (@Axis{"time"} eq "x") {
4332 - if ($at eq "") { $at = @PlotArea{"bottom"}; }
4333 - if ($at > @Image{"height"}) { $at = @Image{"height"}; }
 4462+ if ($Axis{"time"} eq "x") {
 4463+ if ($at eq "") { $at = $PlotArea{"bottom"}; }
 4464+ if ($at > $Image{"height"}) { $at = $Image{"height"}; }
43344465 $script .= " points: $from $at $till $at\n";
43354466 }
43364467 else {
4337 - if ($at eq "") { $at = @PlotArea{"left"}; }
4338 - if ($at > @Image{"width"}) { $at = @Image{"width"}; }
 4468+ if ($at eq "") { $at = $PlotArea{"left"}; }
 4469+ if ($at > $Image{"width"}) { $at = $Image{"width"}; }
43394470 $script .= " points: $at $from $at $till\n";
43404471 }
43414472 }
@@ -4343,24 +4474,24 @@
43444475 {
43454476 @Points = split(",", $points);
43464477 foreach $point (@Points) { $point = &Normalize($point); }
4347 - if ( (@Points[0] > @Image{"width"})
4348 - || (@Points[1] > @Image{"height"})
4349 - || (@Points[2] > @Image{"width"})
4350 - || (@Points[3] > @Image{"height"}))
 4478+ if ( ($Points[0] > $Image{"width"})
 4479+ || ($Points[1] > $Image{"height"})
 4480+ || ($Points[2] > $Image{"width"})
 4481+ || ($Points[3] > $Image{"height"}))
43514482 {
43524483 &Error2(
43534484 "Linedata attribute 'points' invalid.\n"
43544485 . sprintf("(%d,%d)(%d,%d)",
4355 - @Points[0] * 100,
4356 - @Points[1] * 100,
4357 - @Points[2] * 100,
4358 - @Points[3] * 100)
 4486+ $Points[0] * 100,
 4487+ $Points[1] * 100,
 4488+ $Points[2] * 100,
 4489+ $Points[3] * 100)
43594490 . " does not fit in image\n"
43604491 );
43614492 return;
43624493 }
43634494 $script .=
4364 - " points: @Points[0] @Points[1] @Points[2] @Points[3]\n";
 4495+ " points: $Points[0] $Points[1] $Points[2] $Points[3]\n";
43654496 }
43664497 }
43674498
@@ -4378,7 +4509,7 @@
43794510 purple|lavender|lightpurple|powderblue|powderblue2)$/xi
43804511 )
43814512 {
4382 - if (!defined(@Colors{ lc($color) })) {
 4513+ if (!defined($Colors{ lc($color) })) {
43834514 &StoreColor($color, $color, "", $command);
43844515 }
43854516 return ($true);
@@ -4386,18 +4517,26 @@
43874518 else { return ($false); }
43884519 }
43894520
 4521+# Can be much simpler
43904522 sub ValidAbs {
4391 - $value = shift;
4392 - if ($value =~ /^ \d+ \.? \d* (?:px|in|cm)? $/xi) { return ($true); }
4393 - else { return ($false); }
 4523+ my $value = shift;
 4524+ if ($value =~ /^ \d+ \.? \d* (?:px|in|cm)? $/xi) {
 4525+ return ($true);
 4526+ }
 4527+ else {
 4528+ return ($false);
 4529+ }
43944530 }
43954531
 4532+# Can be much simpler
43964533 sub ValidAbsRel {
4397 - $value = shift;
 4534+ my $value = shift;
43984535 if ($value =~ /^ \d+ \.? \d* (?:px|in|cm|$hPerc)? $/xi) {
43994536 return ($true);
44004537 }
4401 - else { return ($false); }
 4538+ else {
 4539+ return ($false);
 4540+ }
44024541 }
44034542
44044543 sub ValidDateFormat {
@@ -4452,8 +4591,8 @@
44534592 my $date = shift;
44544593 my ($day, $month, $year, $dayf, $monthf, $yearf, $dayt, $montht, $yeart);
44554594
4456 - my $from = @Period{"from"};
4457 - my $till = @Period{"till"};
 4595+ my $from = $Period{"from"};
 4596+ my $till = $Period{"till"};
44584597
44594598 if (($DateFormat eq "yyyy") || ($DateFormat eq "x.y")) {
44604599 if (($date < $from) || ($date > $till)) { return ($false); }
@@ -4547,7 +4686,7 @@
45484687 $days -= int(($year - 1 - 1800) / 100);
45494688 if ($month > 1) {
45504689 for ($m = $month - 2; $m >= 0; $m--) {
4551 - $days += @mmm[$m];
 4690+ $days += $mmm[$m];
45524691 if ($m == 1) {
45534692 if ((($year % 4) == 0) && (($year % 100) != 0)) { $days++; }
45544693 }
@@ -4581,8 +4720,8 @@
45824721 }
45834722
45844723 $month = 0;
4585 - while ($days > @mmm[$month]) {
4586 - $days -= @mmm[$month];
 4724+ while ($days > $mmm[$month]) {
 4725+ $days -= $mmm[$month];
45874726 if ($month == 1) {
45884727 if ((($year % 4) == 0) && (($year % 100) != 0)) { $days--; }
45894728 }
@@ -4600,8 +4739,8 @@
46014740 }
46024741
46034742 sub ExtractText {
4604 - my $data = shift;
4605 - my $data2 = $data;
 4743+ # my $data = shift;
 4744+ my $data2 = shift;
46064745 my $text = "";
46074746
46084747 # special case: allow embedded spaces when 'text' is last attribute
@@ -4670,13 +4809,13 @@
46714810 $barcnt--;
46724811 $a = $#Bars;
46734812 for (my $b = 0; $b <= $#Bars; $b++) {
4674 - if (lc(@Bars[$b]) eq lc($barid . $barcnt)) {
 4813+ if (lc($Bars[$b]) eq lc($barid . $barcnt)) {
46754814 $b++;
46764815 for (my $b2 = $#Bars + 1; $b2 > $b; $b2--) {
4677 - @Bars[$b2] = @Bars[ $b2 - 1 ];
 4816+ $Bars[$b2] = $Bars[ $b2 - 1 ];
46784817 }
4679 - @Bars[$b] = lc($bar);
4680 - @BarLegend{ lc($bar) } = " ";
 4818+ $Bars[$b] = lc($bar);
 4819+ $BarLegend{ lc($bar) } = " ";
46814820 return ($true);
46824821 }
46834822 }
@@ -4784,27 +4923,27 @@
47854924 $hint .= "'";
47864925
47874926 foreach $attribute (@Required) {
4788 - if ( (!defined(@Attributes{$attribute}))
4789 - || (@Attributes{$attribute} eq ""))
 4927+ if ( (!defined($Attributes{$attribute}))
 4928+ || ($Attributes{$attribute} eq ""))
47904929 {
47914930 &Error("$name definition incomplete. $hint");
47924931 undef(@Attributes);
47934932 return ($false);
47944933 }
4795 - delete(@Attributes2{$attribute});
 4934+ delete($Attributes2{$attribute});
47964935 }
4797 - foreach $attribute (@Allowed) { delete(@Attributes2{$attribute}); }
 4936+ foreach $attribute (@Allowed) { delete($Attributes2{$attribute}); }
47984937
47994938 @AttrKeys = keys %Attributes2;
48004939 if ($#AttrKeys >= 0) {
4801 - if (@AttrKeys[0] eq "single") {
 4940+ if ($AttrKeys[0] eq "single") {
48024941 &Error(
48034942 "$name definition invalid. Specify all attributes as name:value pairs."
48044943 );
48054944 }
48064945 else {
48074946 &Error( "$name definition invalid. Invalid attribute '"
4808 - . @AttrKeys[0]
 4947+ . $AttrKeys[0]
48094948 . "' found. $hint");
48104949 }
48114950 undef(@Attributes);
@@ -4833,7 +4972,7 @@
48344973 split('\|', $preset);
48354974 if ($attrname eq "") { $attrname = "single"; }
48364975
4837 - $attrvalue = @Attributes{$attrname};
 4976+ $attrvalue = $Attributes{$attrname};
48384977
48394978 if (($action eq "-") && ($attrvalue ne "")) {
48404979 if ($attrname eq "single") {
@@ -4844,15 +4983,15 @@
48454984 &Error("Chosen preset conflicts with '$attrname:...'.\n"
48464985 . " Please remove this attribute.");
48474986 }
4848 - @Attributes{$attrname} = "";
 4987+ $Attributes{$attrname} = "";
48494988 }
48504989
48514990 if (($action eq "+") && ($attrvalue eq "")) {
4852 - if ($addvalue) { @Attributes{$attrname} = $attrpreset; }
 4991+ if ($addvalue) { $Attributes{$attrname} = $attrpreset; }
48534992 }
48544993
48554994 if (($action eq "=") && ($attrvalue eq "")) {
4856 - @Attributes{$attrname} = $attrpreset;
 4995+ $Attributes{$attrname} = $attrpreset;
48574996 }
48584997
48594998 if ( ($action eq "=")
@@ -4869,7 +5008,7 @@
48705009 "Conflicting settings.\nPreset defines '$attrname:$attrpreset'."
48715010 );
48725011 }
4873 - @Attributes{$attrname} = $attrpreset;
 5012+ $Attributes{$attrname} = $attrpreset;
48745013 }
48755014 }
48765015 }
@@ -5161,7 +5300,7 @@
51625301
51635302 open "FILE_OUT", ">", $file_errors;
51645303 print FILE_OUT
5165 - "<p>EasyTimeline $version</p><p><b>Timeline generation failed: "
 5304+ "<p>EasyTimeline $VERSION</p><p><b>Timeline generation failed: "
51665305 . &EncodeHtml($msg)
51675306 . "</b></p>\n";
51685307 foreach $line (@Errors) { print FILE_OUT &EncodeHtml($line) . "\n"; }
@@ -5203,6 +5342,7 @@
52045343 my $unicode = shift;
52055344 my $char = substr($unicode, 0, 1);
52065345 my $ord = ord($char);
 5346+ my $value;
52075347
52085348 if ($ord < 128) # plain ascii character
52095349 {
@@ -5222,8 +5362,11 @@
52235363
52245364 # $html = "\&\#" . $value . ";" ; any unicode can be specified as html char
52255365
5226 - if (($value >= 128) && ($value <= 255)) { return (chr($value)); }
5227 - else { return "?"; }
 5366+ if (($value >= 128) && ($value <= 255)) {
 5367+ return (chr($value));
 5368+ }
 5369+ else {
 5370+ return "?";
 5371+ }
52285372 }
52295373 }
5230 -

Comments

#Comment by 😂 (talk | contribs)   19:38, 17 October 2011

IMHO, we should fix [https://bugzilla.wikimedia.org/show_bug.cgi?id=27156 bug 27156] rather than putting more work into this as-is.

#Comment by Amire80 (talk | contribs)   19:48, 17 October 2011

I replied at bug 27156.

Summary: I will definitely replace Ploticus; currently, refactoring the current Perl code seems cheaper than rewriting in PHP, and it will help the rewriting later.

Status & tagging log