8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / lib / cfgadm_plugins / sbd / sbdgenerr.pl
blob056e3438f9f64fa88719a35e0bb8e230ac513e04
1 #!/usr/bin/perl
3 # CDDL HEADER START
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
8 # with the License.
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
21 # CDDL HEADER END
24 # Copyright (c) 2000 by Sun Microsystems, Inc.
25 # All rights reserved.
28 #pragma ident "%Z%%M% %I% %E% SMI"
30 sub trim {
31 my ($line) = @_;
32 $line =~ s#/\*|\*/##g;
33 $line =~ s#^\s+|\s+$##g;
34 return $line;
37 my $filter = 0;
38 my %prefix;
39 while ($#ARGV >= 0) {
40 $prefix{$ARGV[0]} = 0;
41 shift @ARGV;
42 $filter = 1;
45 my $base;
46 my $bnd;
47 my @text;
48 my @sets;
49 while (<STDIN>) {
50 my $n = m@^#define\s(E\w\w\w)\w+\s+(\d+)(.*)@;
51 next unless ($n > 0);
52 next unless ($filter == 0 || defined $prefix{$1});
53 my $txt = trim($3);
54 if (length($txt) == 0) {
55 my $l = <STDIN>;
56 $txt = trim($l);
59 $base = $2 if (!defined $base);
60 if (defined $bnd && $2 != $bnd + 1) {
61 push(@sets, { base => $base, bnd => $bnd });
62 $base = $2;
64 $bnd = $2;
65 push(@text, $txt);
68 push(@sets, { base => $base, bnd => $bnd });
70 printf "#include <sys/sbd_ioctl.h>\n";
72 my $i = 0;
73 my $s = 0;
74 do {
75 my $set = $sets[$s];
77 printf "static char *sbd_t%d[] = {\n", $set->{base};
78 my $n = $set->{bnd} - $set->{base} + 1;
79 while ($n--) {
80 printf "\t\"%s\",\n", $text[$i++];
82 printf "};\n";
83 } while (++$s <= $#sets);
85 printf "sbd_etab_t sbd_etab[] = {\n";
86 $s = 0;
87 do {
88 my $set = $sets[$s];
89 printf "\t{ %d, %d, sbd_t%d },\n",
90 $set->{base}, $set->{bnd}, $set->{base};
91 } while (++$s <= $#sets);
92 printf "};\n";
93 printf "int sbd_etab_len = %d;\n", $s;