3 ##Convert an Emacs-style TAGS file to a standard ctags file.
4 ##Runs in a single pass over the TAGS file and keeps the first
5 ##tag entry found, and the file name and line number the tag can
7 ##Then it opens all relevant files and builds the regular expression
9 ##Run over a few test files and compared with a real ctags file shows
10 ##only extra tags in the translated file, which probably won't hurt
17 my ($tag,$line_no,$line);
25 ##Grab next line and parse it for the filename
33 ##Figure out how many records in this line and
34 ##extract the tag name and the line that it is found on
37 ($tag,$line_no) = /\x7F(\w+)\x01(\d+)/;
41 ($tag,$line_no) = /(\w+)\s*\x7F(\d+),/;
44 ##Take only the first entry per tag
45 next if defined($tags{$tag});
46 $tags{$tag}{FILE} = $filename;
47 $tags{$tag}{LINE_NO} = $line_no;
48 push @{$filetags{$filename}}, $tag;
51 foreach $filename (keys %files) {
52 open FILE, $filename or die "Couldn't open $filename: $!\n";
56 foreach $tag ( @{$filetags{$filename}} ) {
57 $line = $lines[$tags{$tag}{LINE_NO}-1];
58 if (length($line) >= 50) {
59 $line = substr($line,0,50);
65 $tags{$tag}{LINE} = join '', '/^',$line,'/';
69 foreach $tag ( sort keys %tags ) {
70 print "$tag\t$tags{$tag}{FILE}\t$tags{$tag}{LINE}\n";