From abf5ae6149b594218b578f88827560d62cf1244a Mon Sep 17 00:00:00 2001 From: Warren Toomey Date: Sat, 12 Mar 2016 22:53:33 +1000 Subject: [PATCH] Also print out the routine's filename in xref7. --- tools/xref7 | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tools/xref7 b/tools/xref7 index 38f4d6a..e26c756 100755 --- a/tools/xref7 +++ b/tools/xref7 @@ -7,6 +7,7 @@ # (c) 2016 Warren Toomey, GPL3 use strict; use warnings; + #use Data::Dumper; my %Label; # Hash of labels found @@ -117,13 +118,14 @@ sub parse_file { open( my $IN, "<", $file ) || die("Cannot read $file: $!\n"); while ( my $line = <$IN> ) { chomp($line); # Lose the end of line - parse_line($line); + parse_line( $file, $line ); } close($IN); } sub parse_line { - my $line = shift; + my ( $file, $line ) = @_; + $file =~ s{.*/}{}; # Lose leading whitespace and comments $line =~ s{^\s+}{}; @@ -140,7 +142,10 @@ sub parse_line { if ( !( $label =~ m{^\d+$} ) ) { # Define the label in stage 1 - $Label{$label}{def} = 1 if ( $stage == 1 ); + if ( $stage == 1 ) { + $Label{$label}{def} = 1; + $Label{$label}{file} = $file; + } $curlabel = $label; } } @@ -189,10 +194,11 @@ sub print_output { # Does it have anything useful? my $count = keys( %{ $Label{$curlabel} } ); - next if ( $count == 1 ); # Nope + next if ( $count == 2 ); # Nope print("Function $curlabel\n"); print("==============\n"); + print("File: $Label{$curlabel}{file}\n"); print("Purpose:\n"); print("Arguments:\n"); print("Returns:\n");