eval 'exec perl $0 $1' if $running_under_some_shell; # Build a (sorted) VI(M) tags file including GP functions # $src=$ARGV[0] || "$ENV{HOME}/PARI/src"; $tmptags="$src/tags.tmp"; $tags="$src/tags"; @tags=""; $old=""; # assume ctags outputs sorted tags (e.g Exuberant Ctags) system("ctags -f $tmptags `find $src -name '*.[chs]' -type f -print`"); getnames("$src/gp/gp_init.c"); getnames("$src/language/init.c"); geterrs("$src/language/errmsg.c"); open(T,"$tmptags"); for (sort(@gp)) { ($a, $b) = split(/#/); if ($a eq $old) { push(@tags,"$b$rest\n"); next; } $old = $a; while() { push(@tags,$_); if (/^$a(.*)/) { $rest="$1"; push(@tags,"$b$rest\n"); last; } } } while() { push(@tags,$_); } close(T); open(OUT,">$tags"); print OUT sort(@tags); unlink $tmptags; sub getnames { open(A,$_[0]); while () { if (/^entree functions_/../^$/) { push(@gp,"$2#$1") if (/[^"]*"([^"]*)".*\(void\*\) *([^,]*)/); } } close(A); } sub geterrs { my $f = $_[0]; open(A,$f); while () { if (m,^/(\*\s*\w+\s*\*)/,) { $e = $pat = $1; $e =~ s/\W*(\w+)\W*/$1/; push(@tags, "$e\t$f\t/$pat\n"); } } close(A); }