diff options
author | Allen Winter <allen.winter@kdab.com> | 2015-02-21 18:14:04 -0500 |
---|---|---|
committer | Allen Winter <allen.winter@kdab.com> | 2015-02-21 18:14:04 -0500 |
commit | 78e756a8e9e0dc72cd21d842676f911dcccdc851 (patch) | |
tree | 6359a6dc5a54a04de7ab41874520fbf3876794e2 /scripts/readvaluesfile.pl | |
parent | ad4e57acf60187b2ea1f1db5dae4ad9cdaa84973 (diff) | |
download | libical-git-78e756a8e9e0dc72cd21d842676f911dcccdc851.tar.gz |
scripts - tidy the perl scripts and give them a license header
Diffstat (limited to 'scripts/readvaluesfile.pl')
-rw-r--r-- | scripts/readvaluesfile.pl | 154 |
1 files changed, 86 insertions, 68 deletions
diff --git a/scripts/readvaluesfile.pl b/scripts/readvaluesfile.pl index 1500ec9b..55827577 100644 --- a/scripts/readvaluesfile.pl +++ b/scripts/readvaluesfile.pl @@ -1,132 +1,152 @@ +################################################################################ +# (C) COPYRIGHT 2000, Eric Busboom <eric@softwarestudio.org> +# http://www.softwarestudio.org +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of either: +# +# The LGPL as published by the Free Software Foundation, version +# 2.1, available at: http://www.gnu.org/licenses/lgpl-2.1.txt +# +# Or: +# +# The Mozilla Public License Version 1.0. You may obtain a copy of +# the License at http://www.mozilla.org/MPL/ +################################################################################ + +sub read_values_file +{ - -sub read_values_file { - my $path = shift; my %h; - open(F,$path) || die "Can't open values file $path"; + open(F, $path) || die "Can't open values file $path"; + + while (<F>) { + + chop; - while(<F>){ - - chop; - s/#.*$//g; s/\"//g; s/\r//g; - - next if ! $_; - @column = split(/,/,$_); - + next if !$_; + + @column = split(/,/, $_); + my $value_name = $column[0]; - my $enumConst = $column[1]; + my $enumConst = $column[1]; - my $c_type_str = $column[2]; - my $c_autogen = ($c_type_str =~ /\(a\)/); + my $c_type_str = $column[2]; + my $c_autogen = ($c_type_str =~ /\(a\)/); my $c_type = $c_type_str; $c_type =~ s/\(.\)//; - my $python_type = $column[3]; - my $components = $column[4]; + my $python_type = $column[3]; + my $components = $column[4]; my $enum_values = $column[5]; my @components; - if($components ne "unitary"){ - @components = split(/;/,$components); + if ($components ne "unitary") { + @components = split(/;/, $components); } else { @components = (); } my @enums; - if($enum_values) { - @enums = split(/;/,$enum_values); + if ($enum_values) { + @enums = split(/;/, $enum_values); } else { @enums = (); } - $h{$value_name} = { C => [$c_autogen,$c_type], - kindEnum => $enumConst, - perl => $perl_type, - python => $python_type, - components=>[@components], - enums=>[@enums] - }; + $h{$value_name} = { + C => [$c_autogen, $c_type], + kindEnum => $enumConst, + perl => $perl_type, + python => $python_type, + components => [@components], + enums => [@enums] + }; } return %h; } -sub read_properties_file { - +sub read_properties_file +{ + my $path = shift; my %h; - open(F,$path) || die "Can't open properties file $path"; + open(F, $path) || die "Can't open properties file $path"; + + while (<F>) { + + chop; - while(<F>){ - - chop; - s/#.*$//g; s/\"//g; s/\r//g; - - next if ! $_; - @column = split(/,/,$_); - + next if !$_; + + @column = split(/,/, $_); + my $property_name = $column[0]; - my $enumConst = $column[1]; - my $lic_value = $column[2]; + my $enumConst = $column[1]; + my $lic_value = $column[2]; my $default_value = $column[3]; - - $h{$property_name} = { lic_value => $lic_value, - kindEnum => $enumConst, - default_value => $default_value - }; + + $h{$property_name} = { + lic_value => $lic_value, + kindEnum => $enumConst, + default_value => $default_value + }; } return %h; } -sub read_parameters_file { - +sub read_parameters_file +{ + my $path = shift; my %h; - open(F,$path) || die "Can't open parameters file $path"; + open(F, $path) || die "Can't open parameters file $path"; + + while (<F>) { + + chop; - while(<F>){ - - chop; - s/#.*$//g; s/\"//g; s/\r//g; - - next if ! $_; - @column = split(/\,/,$_); - + next if !$_; + + @column = split(/\,/, $_); + my $parameter_name = $column[0]; - my $enumConst = $column[1]; - my $data_type = $column[2]; + my $enumConst = $column[1]; + my $data_type = $column[2]; my $enum_string = $column[3]; my @enums; - if($enum_string){ - @enums = split(/;/,$enum_string); + if ($enum_string) { + @enums = split(/;/, $enum_string); } - - $h{$parameter_name} = { C => $data_type, - kindEnum => $enumConst, - enums => [@enums] - }; + + $h{$parameter_name} = { + C => $data_type, + kindEnum => $enumConst, + enums => [@enums] + }; } close(F); @@ -134,6 +154,4 @@ sub read_parameters_file { return %h; } - - 1; |