ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra/bin/cf-slotutil
(Generate patch)

Comparing deliantra/Deliantra/bin/cf-slotutil (file contents):
Revision 1.2 by root, Sun Sep 28 07:34:51 2008 UTC vs.
Revision 1.3 by root, Sun Sep 28 13:41:57 2008 UTC

43 43
44 my @res; 44 my @res;
45 45
46 unshift @slots, "_name"; 46 unshift @slots, "_name";
47 47
48 my @sort = grep /^\d+$/, @slots;
48 my @widths = map s/\=(\d+)// && $1, @slots; 49 my @widths = map s/\=(\d+)$// && $1, grep !/^\d+$/, @slots;
50 my @align = map s/>$// ? "" : "-", @slots;
49 my @big; 51 my @big;
50 52
51 local *_; 53 local *_;
52 for (sort keys %ARCH) { 54 for (sort keys %ARCH) {
53 *_ = $ARCH{$_}; 55 *_ = $ARCH{$_};
54 next unless &$filter; 56 next unless &$filter;
55 push @res, [@_{@slots}]; 57 push @res, [@_{@slots}];
56 }; 58 };
59
60 @res = sort {
61 "$a->[$_]$b->[$_]" =~ /^\d+$/
62 ? $a->[$_] <=> $b->[$_]
63 : $a->[$_] cmp $b->[$_]
64 } @res
65 for @sort;
57 66
58 for my $row (@res) { 67 for my $row (@res) {
59 for (0 .. $#$row) { 68 for (0 .. $#$row) {
60 $big[$_] =1 if $row->[$_] =~ /\n/; 69 $big[$_] =1 if $row->[$_] =~ /\n/;
61 } 70 }
66 75
67 for (0 .. $#big) { 76 for (0 .. $#big) {
68 $widths[$_] = length $slots[$_] if $big[$_]; 77 $widths[$_] = length $slots[$_] if $big[$_];
69 } 78 }
70 79
71 my $format = join " ", map "%-${_}s", @widths; 80 my $format = join " ", map "%$align[$_]$widths[$_]s", 0..$#widths;
81
72 printf "$format\n", map "A$_", map $_ + 1, @widths; 82 printf "$format\n", map "A$_", map $_ + 1, @widths;
73 printf "$format\n", @slots; 83 printf "$format\n", @slots;
74 for my $row (@res) { 84 for my $row (@res) {
75 print "\n" if @big; 85 print "\n" if @big;
76 86

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines