dect
/
linux-2.6
Archived
13
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
linux-2.6/drivers/md/unroll.pl

25 lines
492 B
Perl

#!/usr/bin/perl
#
# Take a piece of C code and for each line which contains the sequence $$
# repeat n times with $ replaced by 0...n-1; the sequence $# is replaced
# by the unrolling factor, and $* with a single $
#
($n) = @ARGV;
$n += 0;
while ( defined($line = <STDIN>) ) {
if ( $line =~ /\$\$/ ) {
$rep = $n;
} else {
$rep = 1;
}
for ( $i = 0 ; $i < $rep ; $i++ ) {
$tmp = $line;
$tmp =~ s/\$\$/$i/g;
$tmp =~ s/\$\#/$n/g;
$tmp =~ s/\$\*/\$/g;
print $tmp;
}
}