Skip to content

Commit

Permalink
canonicalize dictionaries using new format
Browse files Browse the repository at this point in the history
to allow ".1" which means "child of previous attribute"
  • Loading branch information
alandekok committed Oct 15, 2018
1 parent a5a3a51 commit e67af39
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions share/format.pl
Expand Up @@ -36,6 +36,7 @@

$begin_vendor = 0;
$blank = 0;
$previous = "";

while (@ARGV) {
$filename = shift;
Expand Down Expand Up @@ -74,6 +75,13 @@
#
s/^\s*([^#])/$1/;

#
# Not an ATTRIBUTE? Suppress "previous" checks.
#
if (!/^ATTRIBUTE/) {
$previous = "";
}

#
# Remember the vendor
#
Expand Down Expand Up @@ -160,6 +168,22 @@
$stuff =~ s/\s+$//;
}

#
# The numerical value doesn't start with ".".
#
# If the current attribute is a child of the previous
# one, then just print out the child values.
#
# Otherwise, remember this attribute as the new "previous"
#
if ($value !~ /^\./) {
if ($value =~ /^$previous(\..+)$/) {
$value = $1;
} else {
$previous = $value;
}
}

push @output, "ATTRIBUTE\t$name$tabs$value\t$type$stuff\n";
next;
}
Expand Down

0 comments on commit e67af39

Please sign in to comment.