[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / glue_TAGS_files.prl
1 #! /usr/local/bin/perl
2 #
3 # glue all the (e)TAGS files named on the command line
4 # into one big TAGS file here; main task: unrelativize the
5 # file names.
6 #
7 open (TAGS, "> TAGS") || die "can't open TAGS file for writing\n";
8
9 foreach $f (@ARGV) {
10     open(INF, "< $f") || die "can't open $f for reading\n";
11     $f =~ s/\/?TAGS$//;
12
13     while (<INF>) {
14         print TAGS $_;
15         next if ! /^\f$/;
16
17         # otherwise, next line is filename; de-relativise it
18         $_ = <INF>;
19         die "unexpected file line:$_" if /^\f/ || /\x7f/; # sanity check
20         if (/^\//) { # absolute already; do nothing...
21             print TAGS $_;
22         } else {
23             print TAGS "$f/$_";
24         }
25     }
26     close(INF);
27 }
28 close(TAGS);