Ethereal-dev: Re: [Ethereal-dev] Consistency checks for hf_ elements

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

Date: Mon, 29 Aug 2005 18:15:19 +0200
> Should we add checks for other things, such as improperly terminated
> value_strings or occurences of sprintf/strcat/g_malloc/etc?

The attached script prints filename and value_string name of any
ununiformely terminated value_strings from all the given files.

usage:
$ perl check_vs.pl epan/dissectors/packet-*.c

Luis
#!/usr/bin/perl


for my $file (@ARGV) {
	open F, "< $file";
	my $b = '';
	
	$b .= $_ while(<F>);

	while ( $b =~ s#static\s+const\s+value_string\s+([a-z_]+)\[\]\s+=\s+{\s*(.*?)\s*}\s*;##ms ) {
		my ($name,$body) = ($1,$2);
		
		chomp $body;
	
		unless ($body =~ /{\s*(0|0x[0]+)\s*,\s*NULL\s*}[,]?$/ms ) {
			print "$file: $name\n";
		}
	}
}