2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-30 05:48:18 +00:00

use strict

This commit is contained in:
Todd C. Miller 2016-08-31 14:33:24 -06:00
parent 7a54b49fc4
commit c9572db75a

View File

@ -10,6 +10,9 @@
# array of struct def_values if TYPE == T_TUPLE
use warnings;
use strict;
my ($header, $cfile, $infile);
# Deal with optional -o (output) argument
if ($#ARGV > 0 && $ARGV[0] eq "-o") {
@ -34,9 +37,10 @@ open(IN, "<$infile") || die "$0: can't open $infile: $!\n";
open(HEADER, ">$header") || die "$0: can't open $header: $!\n";
open(CFILE, ">$cfile") || die "$0: can't open $cfile: $!\n";
$count = 0;
@tuple_values = ( "never" );
@records = ();
my $count = 0;
my @tuple_values = ( "never" );
my @records = ();
my ($var, $type, $desc, $values, $callback, $field);
while (<IN>) {
chomp;
s/\s*#.*$//;
@ -76,7 +80,7 @@ while (<IN>) {
} else {
die "$0: syntax error near line $.\n" if $type !~ /^T_TUPLE/;
$values = [ split ];
foreach $v (@$values) {
foreach my $v (@$values) {
push(@tuple_values, $v) unless grep(/^$v$/, @tuple_values);
}
}
@ -88,11 +92,12 @@ while (<IN>) {
$records[$count++] = [$var, $type, $desc, $values, $callback] if defined($var);
# Print out value arrays
for ($i = 0; $i < $count; $i++) {
for (my $i = 0; $i < $count; $i++) {
if (defined($records[$i]->[3])) {
die "Values list specified for non-tuple\n" unless
$records[$i]->[1] =~ /^T_TUPLE/;
printf CFILE "static struct def_values def_data_%s[] = {\n", $records[$i]->[0];
printf CFILE "static struct def_values def_data_%s[] = {\n",
$records[$i]->[0];
foreach (@{$records[$i]->[3]}) {
print CFILE " { \"$_\", $_ },\n";
}
@ -103,7 +108,7 @@ for ($i = 0; $i < $count; $i++) {
# Print each record
print CFILE "struct sudo_defs_types sudo_defs_table[] = {\n {\n";
for ($i = 0; $i < $count; $i++) {
for (my $i = 0; $i < $count; $i++) {
print_record($records[$i], $i);
}
print CFILE "\tNULL, 0, NULL\n }\n};\n";
@ -111,7 +116,7 @@ print CFILE "\tNULL, 0, NULL\n }\n};\n";
# Print out def_tuple
if (@tuple_values) {
print HEADER "\nenum def_tuple {\n";
for ($i = 0; $i <= $#tuple_values; $i++) {
for (my $i = 0; $i <= $#tuple_values; $i++) {
printf HEADER "\t%s%s\n", $tuple_values[$i],
$i != $#tuple_values ? "," : "";
}