X-Git-Url: https://git.jankratochvil.net/?p=nethome.git;a=blobdiff_plain;f=bin%2Fcheckstatic;h=d26259a3551ff29d15fd496587da2f7b12fbdb56;hp=f2d4911c9c16a8db32e86885816794fb00c61d19;hb=HEAD;hpb=f3d6c77d1e5d5108089e59d4b7344d83c36d6704 diff --git a/bin/checkstatic b/bin/checkstatic index f2d4911..d26259a 100755 --- a/bin/checkstatic +++ b/bin/checkstatic @@ -7,10 +7,16 @@ use Data::Dumper; use Getopt::Long; -our(%symtab)=(); - -our($D); -die if !GetOptions("d|debug+",\$D); +my(%symtab)=(); + +my $D; +my $opt_nm="nm"; +my $opt_headers=1; +die if !GetOptions( + "d|debug+",\$D, + "nm=s" ,\$opt_nm, + "headers!",\$opt_headers, + ); sub defmiss @@ -45,7 +51,7 @@ my(%sym)=@_; }); } -open(NM,"-|",'find -name "*.o"|xargs nm -f posix --print-file-name --no-sort --line-numbers') +open(NM,"-|",'find -name "*.o"|xargs -- '.$opt_nm.' -f posix --print-file-name --no-sort --line-numbers') or die "Cannot get nm output: $!"; while () { chomp; @@ -61,20 +67,22 @@ while () { } close NM; -open(CTAGS,"-|",'find -name "*.h"|xargs ctags -f - --c-types=xp') - or die "Cannot get ctags output: $!"; -while () { - chomp; - die "Line $. of ctags output not recognized: $_" - # $1 $2 $3 - if !/^([^\t]*)\t([^\t]*)\t.*\t(\w)$/; - storesym( - "name"=>$1, - "fn_c"=>$2, - "type"=>"c$3", - ); +if ($opt_headers) { + open(CTAGS,"-|",'find -name "*.h"|xargs ctags -f - --c-types=xp') + or die "Cannot get ctags output: $!"; + while () { + chomp; + die "Line $. of ctags output not recognized: $_" + # $1 $2 $3 + if !/^([^\t]*)\t([^\t]*)\t.*\t(\S+)$/; + storesym( + "name"=>$1, + "fn_c"=>$2, + "type"=>"c$3", + ); + } + close CTAGS; } -close CTAGS; print Data::Dumper->Dump([\%symtab],["%symtab"]) if $D; @@ -124,7 +132,7 @@ foreach $symname (sort keys %symtab) { } # >=1 n[:upper:]\U symbol && ==0 nU symbol => global singularity - if (@{refendef($ref=$$typesref{"n+"})}>=1 && @{refendef($$typesref{"n-"})}==0) { + if (@{refendef($ref=$$typesref{"n+"})}>=1 && @{refendef($$typesref{"nU"})}==0) { dumpsyms("global singularity",@{$ref}); }