From 2adc42e43e7a4a96c40eecd378225b4838d28d99 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bodo=20M=C3=B6ller?= Date: Sun, 8 Jan 2006 21:43:36 +0000 Subject: [PATCH] Detect more errors. Change assignment strategy: rathern than using max+r for new codes, find first hole in list of existing codes. --- util/mkerr.pl | 48 +++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/util/mkerr.pl b/util/mkerr.pl index a5ba05a796..399b10e1a3 100644 --- a/util/mkerr.pl +++ b/util/mkerr.pl @@ -65,6 +65,8 @@ while() $csrc{$1} = $3; $fmax{$1} = 99; $rmax{$1} = 99; + $fassigned{$1} = ":"; + $rassigned{$1} = ":"; $fnew{$1} = 0; $rnew{$1} = 0; } @@ -171,7 +173,7 @@ while (($hdr, $lib) = each %libinc) # maximum code used. if ($gotfile) { - while() { + while() { if(/^\#define\s+(\S+)\s+(\S+)/) { $name = $1; $code = $2; @@ -182,26 +184,40 @@ while (($hdr, $lib) = each %libinc) } if($1 eq "R") { $rcodes{$name} = $code; + if ($rassigned{$lib} =~ /:$code:/) { + print STDERR "!! ERROR: $lib reason code $code assigned twice\n"; + } + $rassigned{$lib} .= "$code:"; if(!(exists $rextra{$name}) && ($code > $rmax{$lib}) ) { $rmax{$lib} = $code; } } else { + if ($fassigned{$lib} =~ /:$code:/) { + print STDERR "!! ERROR: $lib function code $code assigned twice\n"; + } + $fassigned{$lib} .= "$code:"; if($code > $fmax{$lib}) { $fmax{$lib} = $code; } $fcodes{$name} = $code; } } - } + } } if ($debug) { - if (defined($rmax{$lib})) { - print STDERR "Max reason code rmax" . "{" . "$lib" . "} = $rmax{$lib}\n"; - } if (defined($fmax{$lib})) { print STDERR "Max function code fmax" . "{" . "$lib" . "} = $fmax{$lib}\n"; + $fassigned{$lib} =~ m/^:(.*):$/; + @fassigned = sort {$a <=> $b} split(":", $1); + print STDERR " @fassigned\n"; + } + if (defined($rmax{$lib})) { + print STDERR "Max reason code rmax" . "{" . "$lib" . "} = $rmax{$lib}\n"; + $rassigned{$lib} =~ m/^:(.*):$/; + @rassigned = sort {$a <=> $b} split(":", $1); + print STDERR " @rassigned\n"; } } @@ -381,7 +397,16 @@ EOF foreach $i (@function) { $z=6-int(length($i)/8); if($fcodes{$i} eq "X") { - $fcodes{$i} = ++$fmax{$lib}; + $fassigned{$lib} =~ m/^:([^:]*):/; + $findcode = $1; + if (!defined($findcode)) { + $findcode = $fmax{$lib}; + } + while ($fassigned{$lib} =~ m/:$findcode:/) { + $findcode++; + } + $fcodes{$i} = $findcode; + $fassigned{$lib} .= "$findcode:"; print STDERR "New Function code $i\n" if $debug; } printf OUT "#define $i%s $fcodes{$i}\n","\t" x $z; @@ -392,7 +417,16 @@ EOF foreach $i (@reasons) { $z=6-int(length($i)/8); if($rcodes{$i} eq "X") { - $rcodes{$i} = ++$rmax{$lib}; + $rassigned{$lib} =~ m/^:([^:]*):/; + $findcode = $1; + if (!defined($findcode)) { + $findcode = $rmax{$lib}; + } + while ($rassigned{$lib} =~ m/:$findcode:/) { + $findcode++; + } + $rcodes{$i} = $findcode; + $rassigned{$lib} .= "$findcode:"; print STDERR "New Reason code $i\n" if $debug; } printf OUT "#define $i%s $rcodes{$i}\n","\t" x $z; -- 2.34.1