#! /usr/bin/perl # Copyright (c) Perforce Software, Inc., 1997-2008. All rights reserved # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PERFORCE # SOFTWARE, INC. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # User contributed content on the Perforce Public Depot is not supported # by Perforce, although it may be supported by its author. This applies # to all contributions even those submitted by Perforce employees. #This is intended as a read-only protections viewer. #Test with the following: #protpp.pl > p1 #p4 protect -o | /bin/grep -v ^# | /bin/grep -v ^Prot > p2 #diff -wbE p1 p2 #It's ok if diff tells you about the leading blank line in p2. my @protx; #reconstituted table $spaces[0] = 0; #spaces between entries $spaces[1] = 0; $spaces[2] = 0; $spaces[3] = 0; $spaces[4] = 0; $run = 0; open PROT, "p4 protect -o | " or die "Couldn't run \"p4 protect -o\"\n"; while ( <PROT> ) { #write user * * //... #0 1 2 3 4 $prot[run] = $_; chomp; if(/^Protections/) { next;} if(/^\#/) { next; } if( (length $_) == 0) { next; } @t1 = split; for($x = 0; $x < 4; $x++) { if ( ( length $t1[$x] ) > $spaces[$x] ) { $spaces[$x] = ( length $t1[$x] ); } } @protx[$run] = @prot; $run++; } for($z = 0; $z <= $run; $z++) { $line = $protx[$z]; @s = split (/\s/, $line); for($y = 1; $y <= 4; $y++) { $diff = $spaces[$y-1] - ( length $s[$y] ) + 1; print $s[$y] . " "x$diff . " "; } shift @s;shift @s; shift @s; shift @s; shift @s; if("@s" !~ /^-/) { print " "; } if("@s" !~ /^\"/) { print " "; } print "@s"; print "\n"; } exit 0;
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#6 | 7897 | Jason Gibson | Pretty-printer trigger for protections and client specs. | ||
#5 | 7494 | Jason Gibson | Add license headers. | ||
#4 | 5305 | Jason Gibson |
Some changes. Added some more description. |
||
#3 | 5304 | Jason Gibson |
"le" is still not equal to "<=". protpp.pl now prints the whole table out correctly. |
||
#2 | 5295 | Jason Gibson |
Fixed a bug. Apparently ">" isn't the same as "gt". |
||
#1 | 5294 | Jason Gibson |
First draft of a protections table pretty printer. The script makes evenly aligned columns for easier viewing. |