You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
588 B
42 lines
588 B
5 years ago
|
use String::CRC32;
|
||
|
|
||
|
sub ReadInputFileWithIncludes
|
||
|
{
|
||
|
local( $filename ) = shift;
|
||
|
|
||
|
local( *INPUT );
|
||
|
local( $output );
|
||
|
|
||
|
open INPUT, "<$filename" || die;
|
||
|
|
||
|
local( $line );
|
||
|
local( $linenum ) = 1;
|
||
|
while( $line = <INPUT> )
|
||
|
{
|
||
|
if( $line =~ m/\#include\s+\"(.*)\"/i )
|
||
|
{
|
||
|
$output.= ReadInputFileWithIncludes( $1 );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$output .= $line;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
close INPUT;
|
||
|
return $output;
|
||
|
}
|
||
|
|
||
|
if( !scalar( @ARGV ) )
|
||
|
{
|
||
|
die "Usage: crc32filewithincludes.pl filename\n";
|
||
|
}
|
||
|
|
||
|
$data = &ReadInputFileWithIncludes( shift );
|
||
|
|
||
|
#print "data: $data\n";
|
||
|
|
||
|
$crc = crc32( $data );
|
||
|
print $crc;
|
||
|
exit 0;
|