8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / sgs / tools / lint_hdr.pl
blobf08b65af66fb5e5d265f8c5d64d6ea51ce09b9c1
1 #!/usr/bin/perl
4 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
5 # Use is subject to license terms.
7 # CDDL HEADER START
9 # The contents of this file are subject to the terms of the
10 # Common Development and Distribution License (the "License").
11 # You may not use this file except in compliance with the License.
13 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
14 # or http://www.opensolaris.org/os/licensing.
15 # See the License for the specific language governing permissions
16 # and limitations under the License.
18 # When distributing Covered Code, include this CDDL HEADER in each
19 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
20 # If applicable, add the following below this CDDL HEADER, with the
21 # fields enclosed by brackets "[]" replaced with your own identifying
22 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # CDDL HEADER END
26 #ident "%Z%%M% %I% %E% SMI"
30 # Generate a header for lint output for subdirectories of
31 # usr/src/cmd/sgs, of the form:
33 # lint_hdr [-s] target_file [elfclass]
35 # where:
36 # target - Name of main target (library or program name)
37 # elfclass - If present, 32 or 64, giving the ELFCLASS of
38 # the code being linted.
40 # The resulting header looks like the following:
42 # [elfclass - ]target [sgssubdir]
43 # ----------------------------------------------------
45 # If the elfclass is omitted, then the header does not include
46 # it. If the target matches 'dirname sgssubdir', then sgssubdir
47 # is displayed without the target and without the square brackets.
49 # The -s option specifies that this is a sub-header, used when
50 # multiple lints are done within a single target. If -s is specified,
51 # the sgssubdir is not shown (presumably it was already shown in an earlier
52 # call to link_hdr), and a shorter dashed line is used:
54 # [elfclass - ]target
55 # ========================
58 use warnings;
59 use strict;
60 use Cwd;
62 use vars qw($script $usage $dir $argc $target $elfclass);
63 use vars qw($sub);
65 $script = 'lint_hdr';
66 $usage = "usage: $script target [elfclass]\n";
68 $sub = 0;
69 die $usage if (scalar(@ARGV) == 0);
70 while ($_ = $ARGV[0],/^-/) {
71 ARG: {
72 if (/^-s$/) {
73 $sub = 1;
74 last ARG;
77 # If it gets here, it's an unknown option
78 die $usage;
80 shift;
83 $argc = scalar(@ARGV);
84 die $usage if (($argc < 1) || ($argc > 2));
85 $target = $ARGV[0];
86 $elfclass = ($argc == 2) ? "Elf$ARGV[1] - " : '';
88 if ($sub) {
89 print "\n$elfclass$target\n========================\n";
90 exit 0;
93 # Clip the path up through ..sgs/, leaving the path from sgs to current dir
94 $dir = getcwd();
95 $dir = "$1" if $dir =~ /\/sgs\/(.*)$/;
97 # Normally, we format the target and directory like this:
98 # target [dir]
99 # However, if this is the special case where $dir is equal to
100 # prog/mach
101 # and prog matches our target name, then just show dir without brackets.
102 if (($dir =~ /^([^\/]+)\/[^\/]+$/) && ($1 eq $target)) {
103 $target = '';
104 } else {
105 $dir = " [$dir]";
108 print "\n$elfclass$target$dir\n";
109 print "------------------------------------------------------------\n";
111 exit 0;