Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 422e4c7

Browse files
author
Werner Almesberger
committed
boom: order component references correctly
- misc.pl (cmp_cref): helper function to order component references by name and number - part2order: sort component references using cmp_cref - prettyord: sort component references using cmp_cref
1 parent f098aa8 commit 422e4c7

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

‎eda/boom/misc.pl‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,20 @@ sub dsc_xlat_arg
7676
}
7777

7878

79+
#
80+
# Lexical ordering of component references
81+
#
82+
83+
sub cmp_cref
84+
{
85+
local ($a, $b) = @_;
86+
local ($as, $an, $bs, $bn);
87+
88+
return $a cmp $b unless ($as, $an) = $a =~ /^([[:alpha:]]+)(\d*)$/;
89+
return $a cmp $b unless ($bs, $bn) = $b =~ /^([[:alpha:]]+)(\d*)$/;
90+
return $as cmp $bs unless $as eq $bs;
91+
return $an <=> $bn
92+
}
93+
94+
7995
return 1;

‎eda/boom/part2order‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ for (sort { &rank($b, $a) } keys %want) {
104104
while (keys %{ $comps{$id} }) {
105105
last if $best_qty < $mult;
106106
$best_qty -= $mult;
107-
my $ref = (sort keys %{ $comps{$id} })[0];
107+
my $ref = (sort { &cmp_cref($a, $b); } keys %{ $comps{$id} })[0];
108108
#print STDERR "$id: $ref + ", join("|", keys %{ $comps{$id} }), "\n";
109109
my @f = @{ $parts{$ref} };
110110
while (@f) {

‎eda/boom/prettyord‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ if ($shop) {
5555
$out[4][0] = "Ref";
5656
}
5757

58-
for (sort { $by_pn ? $a cmp $b : $order{$a}[3]cmp$order{$b}[3] }
58+
for (sort { $by_pn ? $a cmp $b : &cmp_cref($order{$a}[3], $order{$b}[3]) }
5959
keys %order) {
6060
push(@{ $out[0] }, ++$n);
6161
push(@{ $out[1] }, $shop ? $order{$_}[0] : @{ $order{$_} }-3);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /