mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Improve generation of list of supported dive computers
Get it straight from the libdivecomputer sources used... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
5ea2c6c237
commit
7129115999
3 changed files with 76 additions and 43 deletions
67
scripts/parse-descriptor.pl
Normal file → Executable file
67
scripts/parse-descriptor.pl
Normal file → Executable file
|
@ -1,37 +1,64 @@
|
|||
#!/bin/perl
|
||||
#
|
||||
# Extract supported divecomputers from libdivecomputer source
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# parse-descriptor.pl <path to libdivecomputer/src/descriptor.c> <outfile>
|
||||
#
|
||||
# depending on suffix of the outfile it creates the right content for
|
||||
# either a text file or and html file
|
||||
use Carp;
|
||||
|
||||
#set command line arguments
|
||||
my ($infi, $outfi) = @ARGV;
|
||||
my ($type) = $outfi =~ /\.([^.]+)$/;
|
||||
|
||||
if ($infi !~ /.*descriptor.c/) {
|
||||
croak "run as $ARGV[0] <path to descriptor.c> <outputfile>\n";
|
||||
}
|
||||
|
||||
open(my $fh, "<", $infi) || croak "can't open $infi: $!";
|
||||
open(STDOUT, ">", $outfi) || croak "can't open $outfi: $!";
|
||||
|
||||
my $lastVend = "";
|
||||
my @descriptors = ();
|
||||
while (<$fh>) {
|
||||
my ($vend, $mod, $set) = split('\t', $_);
|
||||
if ($type eq "html") {
|
||||
if ($vend eq $lastVend) {
|
||||
printf(", %s", $mod);
|
||||
} else {
|
||||
if ($lastVend eq "") {
|
||||
printf("<dl><dt>%s</dt><dd>\n\t<ul>\n\t <li>%s", $vend, $mod);
|
||||
} else {
|
||||
printf("</li>\n\t</ul>\n </dd>\n <dt>%s</dt><dd>\n\t<ul>\n\t <li>%s", $vend, $mod);
|
||||
}
|
||||
if (/^\s*{\s*"([^\,]*)"\s*,\s*"([^\,]*)"\s*,\s*([^\,]*).*}/) {
|
||||
push(@descriptors, "$1,$2");
|
||||
}
|
||||
} else {
|
||||
if ($vend eq $lastVend) {
|
||||
printf(", %s", $mod);
|
||||
}
|
||||
my @sortedDescriptors = sort @descriptors;
|
||||
foreach (@sortedDescriptors) {
|
||||
($vend, $mod) = split(',', $_);
|
||||
if ($type eq "html") {
|
||||
if ($vend eq $lastVend) {
|
||||
printf(", %s", $mod);
|
||||
} else {
|
||||
if ($lastVend lt "Uemis" && $vend gt "Uemis") {
|
||||
printf("</li>\n\t</ul>\n </dd>\n <dt>Uemis</dt><dd>\n\t<ul>\n\t <li>Zürich SDA");
|
||||
}
|
||||
if ($lastVend eq "") {
|
||||
printf("<dl><dt>%s</dt><dd>\n\t<ul>\n\t <li>%s", $vend, $mod);
|
||||
} else {
|
||||
printf("</li>\n\t</ul>\n </dd>\n <dt>%s</dt><dd>\n\t<ul>\n\t <li>%s", $vend, $mod);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($lastVend eq "") {
|
||||
printf("%s: %s", $vend, $mod);
|
||||
} else {
|
||||
printf("\n%s: %s", $vend, $mod);
|
||||
}
|
||||
if ($vend eq $lastVend) {
|
||||
printf(", %s", $mod);
|
||||
} else {
|
||||
if ($lastVend lt "Uemis" && $vend gt "Uemis") {
|
||||
printf("\nUemis: Zürich SDA");
|
||||
}
|
||||
if ($lastVend eq "") {
|
||||
printf("%s: %s", $vend, $mod);
|
||||
} else {
|
||||
printf("\n%s: %s", $vend, $mod);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$lastVend = $vend;
|
||||
$lastVend = $vend;
|
||||
}
|
||||
if ($type eq "html") {
|
||||
print("</li>\n\t</ul>\n </dd>\n</dl>");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue