aboutsummaryrefslogtreecommitdiff
path: root/fixtags.pl
blob: ce7567f4133998aee6c8dfdda11a2e418dfa0ece (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/perl -w

# read a ctags file. for every tag found, create its
# corresponding tag with or without leading _.
# vim wants the tagfile sorted, so do that, too.

$file = $ARGV[0];
while(<>) {
	push @tags, $_;
	next if /^!/; # skip ctags magic tags

	# skip C #defines
	my @fields = split '\t';
	next if $fields[1] =~ /\.c$/ && $fields[3] =~ /^d$/;

	if(/^_/) {
		s/^_//;
	} else {
		s/^/_/;
	}
	push @tags, $_;
}

open OUT, ">$file" or die $!;
print OUT for sort @tags;