diff options
-rwxr-xr-x | scripts/mkrestrictiontable.pl | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/scripts/mkrestrictiontable.pl b/scripts/mkrestrictiontable.pl index 21bc499a..ca8c8355 100755 --- a/scripts/mkrestrictiontable.pl +++ b/scripts/mkrestrictiontable.pl @@ -47,8 +47,9 @@ if ($opt_i) { sub insert_code { - # First build the property restriction table - print "static const icalrestriction_property_record icalrestriction_property_records[] = {\n"; + # First parse the restrictions file and make a hash of the restrictions + my @prop_restr = (); + my @comp_restr = (); while (<F>) { @@ -67,17 +68,36 @@ sub insert_code } $restr =~ s/\s+$//; - if ($prop ne "NONE") { - print( -" \{ICAL_METHOD_${method}, ICAL_${targetcomp}_COMPONENT, ICAL_${prop}_PROPERTY, ICAL_RESTRICTION_${restr}, $sub},\n" - ); + if ($prop eq "NONE") { + $prop = "NO"; + } + if ($subcomp eq "NONE") { + $subcomp = "NO"; } + my @value = ($restr, $sub); + $prop_restr{$method}{$targetcomp}{$prop}{$subcomp} = \@value; } + # Build the restriction table + print "static const icalrestriction_record icalrestriction_records[] = {\n"; + + for $method ( sort keys %prop_restr ) { + for $targetcomp ( sort keys %{ $prop_restr{$method} } ) { + for $prop ( sort keys %{ $prop_restr{$method}{$targetcomp} } ) { + for $subcomp ( sort keys %{ $prop_restr{$method}{$targetcomp}{$prop} } ) { + my ($restr, $sub) = @{$prop_restr{$method}{$targetcomp}{$prop}{$subcomp}}; + print( +" \{ICAL_METHOD_${method}, ICAL_${targetcomp}_COMPONENT, ICAL_${prop}_PROPERTY, ICAL_${subcomp}_COMPONENT, ICAL_RESTRICTION_${restr}, $sub},\n" + ); + } + } + } +} + # Print the terminating line print - " {ICAL_METHOD_NONE, ICAL_NO_COMPONENT, ICAL_NO_PROPERTY, ICAL_RESTRICTION_NONE, NULL}\n"; + " {ICAL_METHOD_NONE, ICAL_NO_COMPONENT, ICAL_NO_PROPERTY, ICAL_NO_COMPONENT, ICAL_RESTRICTION_NONE, NULL}\n"; print "};\n"; |