From: Nicholas Clark Date: Wed, 17 Mar 2010 16:41:27 +0000 (+0000) Subject: Change regcomp.pl to 0-based indexing for its arrays and loops. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=93882df08ca38a02b0381419b29fff019ec87ef7;p=p5sagit%2Fp5-mst-13.2.git Change regcomp.pl to 0-based indexing for its arrays and loops. --- diff --git a/regcomp.pl b/regcomp.pl index fdfa7e6..6a61f98 100644 --- a/regcomp.pl +++ b/regcomp.pl @@ -35,10 +35,10 @@ while () { next; } unless ($lastregop) { - $ind++; ($name[$ind], $desc, $rest[$ind]) = /^(\S+)\s+([^\t]+)\s*;\s*(.*)/; ($type[$ind], $code[$ind], $args[$ind], $flags[$ind], $longj[$ind]) = split /[,\s]\s*/, $desc; + ++$ind; } else { my ($type,@lists)=split /\s+/, $_; die "No list? $type" if !@lists; @@ -60,10 +60,10 @@ while () { die "unknown :type ':$special'"; } foreach my $suffix (@suffix) { - $ind++; $name[$ind]="$real$suffix"; $type[$ind]=$type; $rest[$ind]="state for $type"; + ++$ind; } } } @@ -85,9 +85,9 @@ sub process_flags { $ind = 0; my @selected; - while (++$ind <= $lastregop) { + do { push @selected, $name[$ind] if $flags[$ind] && $flags[$ind] eq $flag; - } + } while (++$ind < $lastregop); my $out_string = join ', ', @selected, 0; $out_string =~ s/(.{1,70},) /$1\n /g; return $comment . <<"EOP"; @@ -128,15 +128,14 @@ EOP ; -for ($ind=1; $ind <= $lastregop ; $ind++) { - my $oind = $ind - 1; +for ($ind=0; $ind < $lastregop ; ++$ind) { printf $out "#define\t%*s\t%d\t/* %#04x %s */\n", - -$width, $name[$ind], $ind-1, $ind-1, $rest[$ind]; + -$width, $name[$ind], $ind, $ind, $rest[$ind]; } print $out "\t/* ------------ States ------------- */\n"; -for ( ; $ind <= $tot ; $ind++) { +for ( ; $ind < $tot ; $ind++) { printf $out "#define\t%*s\t(REGNODE_MAX + %d)\t/* %s */\n", - -$width, $name[$ind], $ind - $lastregop, $rest[$ind]; + -$width, $name[$ind], $ind - $lastregop + 1, $rest[$ind]; } print $out <