# HG changeset patch # User Matti Hamalainen # Date 1440421510 -10800 # Node ID eaac0a84a7d295e5311ad0d281561fac18ee61f3 # Parent d98aaa5404590f39a747c1548b4203561cef84da Cosmetics. diff -r d98aaa540459 -r eaac0a84a7d2 parsedata.pl --- a/parsedata.pl Mon Aug 24 12:19:59 2015 +0300 +++ b/parsedata.pl Mon Aug 24 16:05:10 2015 +0300 @@ -328,9 +328,9 @@ } -sub getDataStruct($$); +sub get_hour_data_struct($$); -sub getDataStruct($$) +sub get_hour_data_struct($$) { my @out = (); my ($tmp, $first) = @_; @@ -340,7 +340,7 @@ my @str = (); foreach my $item (@{$tmp}) { - push(@str, getDataStruct($item, 0)); + push(@str, get_hour_data_struct($item, 0)); } if (scalar(@str) > 0) { @@ -353,8 +353,8 @@ my @str = (); foreach my $key (keys %{$tmp}) { - push(@out, "\"".$key."\" => ".getDataStruct($$tmp{$key}, 1)) if ($opt_mode eq "php"); - push(@out, "<".$key.">".getDataStruct($$tmp{$key}, 1)."") if ($opt_mode eq "xml"); + push(@out, "\"".$key."\" => ".get_hour_data_struct($$tmp{$key}, 1)) if ($opt_mode eq "php"); + push(@out, "<".$key.">".get_hour_data_struct($$tmp{$key}, 1)."") if ($opt_mode eq "xml"); } if (scalar(@str) > 0) { @@ -527,7 +527,8 @@ binmode STDOUT, ':encoding(utf-8)'; ### Output data in desired format -if ($opt_mode eq "php") { +if ($opt_mode eq "php") +{ print " array(".join(", ", map { "\"".escape($_)."\""; } @{$class{"info"}})."),\n". @@ -540,14 +541,16 @@ ");\n\n"; print "\$classHourTimes = array(\n"; - foreach my $chour (@$hourTimes) { + foreach my $chour (@$hourTimes) + { print " array(\"start\" => ".$$chour{"start"}.", \"end\" => ".$$chour{"end"}."),\n"; } print ");\n\n"; print "\$classHourDefs = array(\n"; - foreach my $cid (sort { $a <=> $b } keys %{$hourDefs}) { - print " $cid => array(".getDataStruct($$hourDefs{$cid}, 0)."),\n"; + foreach my $cid (sort { $a <=> $b } keys %{$hourDefs}) + { + print " $cid => array(".get_hour_data_struct($$hourDefs{$cid}, 0)."),\n"; } print ");\n\n"; @@ -563,7 +566,8 @@ print ");\n?>\n"; } -elsif ($opt_mode eq "xml") { +elsif ($opt_mode eq "xml") +{ print "\n". "\n". " \n". @@ -577,15 +581,17 @@ print " \n"; my $cid = 0; - foreach my $chour (@$hourTimes) { + foreach my $chour (@$hourTimes) + { print " ".$$chour{"start"}."".$$chour{"end"}."\n"; $cid++; } print " \n\n"; print " \n"; - foreach $cid (sort { $a <=> $b } keys %{$hourDefs}) { - print " ".getDataStruct($$hourDefs{$cid}, 0)."\n"; + foreach $cid (sort { $a <=> $b } keys %{$hourDefs}) + { + print " ".get_hour_data_struct($$hourDefs{$cid}, 0)."\n"; } print " \n\n";