Avoid duplicate entries when parsing libdivecomputer descriptors

This just fixes the tool used for the next commit.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2017-01-14 19:22:21 -08:00
parent 1ab6e7fc8a
commit cc8ee5ab96

View file

@ -22,6 +22,7 @@ open(my $fh, "<", $infi) || croak "can't open $infi: $!";
open(STDOUT, ">", $outfi) || croak "can't open $outfi: $!"; open(STDOUT, ">", $outfi) || croak "can't open $outfi: $!";
my $lastVend = ""; my $lastVend = "";
my $lastMod = "";
my @descriptors = (); my @descriptors = ();
while (<$fh>) { while (<$fh>) {
if (/^\s*{\s*"([^\,]*)"\s*,\s*"([^\,]*)"\s*,\s*([^\,]*).*}/) { if (/^\s*{\s*"([^\,]*)"\s*,\s*"([^\,]*)"\s*,\s*([^\,]*).*}/) {
@ -31,6 +32,7 @@ while (<$fh>) {
my @sortedDescriptors = sort @descriptors; my @sortedDescriptors = sort @descriptors;
foreach (@sortedDescriptors) { foreach (@sortedDescriptors) {
($vend, $mod) = split(',', $_); ($vend, $mod) = split(',', $_);
next if ($vend eq $lastVend && $mod eq $lastMod);
if ($type eq "html") { if ($type eq "html") {
if ($vend eq $lastVend) { if ($vend eq $lastVend) {
printf(", %s", $mod); printf(", %s", $mod);
@ -59,6 +61,7 @@ foreach (@sortedDescriptors) {
} }
} }
$lastVend = $vend; $lastVend = $vend;
$lastMod = $mod;
} }
if ($type eq "html") { if ($type eq "html") {
print("</li>\n\t</ul>\n </dd>\n</dl>"); print("</li>\n\t</ul>\n </dd>\n</dl>");