Skip to content

Commit

Permalink
Parse line-continuations when reading definitions.units.patched
Browse files Browse the repository at this point in the history
  • Loading branch information
df7cb committed May 17, 2022
1 parent 5af8365 commit 95f2b7a
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions load-units.pl
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,33 @@

my $skip_british = 0;
my @todo;
my $continued = '';

while (<F>) {
# skip over locale specific parts
$skip_british = 1 if /^!var UNITS_ENGLISH GB/;
$skip_british = 0 if /^!endvar/;
next if ($skip_british);

if (/\s*(.*)\\$/) {
$continued .= $1;
next;
} elsif ($continued) {
s/^\s*//;
$_ = "$continued$_";
$continued = '';
}

s/#.*//;
s/\s+$//;
next if /^\s*$/; # skip emtpy lines
next if /^!/; # skip pragmas
next if /^\+/; # skip units from non-SI systems
next if /^[0-9]/; # skip over table contents
next if /^\s/; # skip over table contents/continued lines
#next if /^[0-9]/; # skip over table contents
#next if /^\s/; # skip over table contents/continued lines
unless (/^(\S+)\s+(.*)/) {
print "skipping $_\n";
next;
print "unknown line $_\n";
exit 1;
}

my ($unit, $def) = ($1, $2);
Expand Down

0 comments on commit 95f2b7a

Please sign in to comment.