#!/usr/bin/perl # -*- cperl -*- use Getopt::Std; getopts('p:r:s:a:f:CTNGhu'); if (@ARGV<1 or $opt_h or $opt_u) { print "Usage: $0 [-s strip-sfx] [-a append-sfx] [-p strip-prefix] [-r add-prefix] [-f out-fmt] [-T] [-N] [-G] file [file ...]\n"; if ($opt_h) { print < 'FSBackend', csts => 'CSTS_SGML_SP_Backend', trxml => 'TrXMLBackend' ); $fileno=0; $filecount=scalar(@ARGV); $format=defined($opt_f) ? lc($opt_f) : "csts"; unless ( $backend = $bkmap{$format} ) { die "Unknown format $format. Use -f [fs|csts|trxml]\n"; } foreach $f (@ARGV) { $fileno++; print STDERR "$f\t",int(100*$fileno / $filecount),"%\t$fileno of $filecount\n"; $fs = FSFile->newFSFile($f,@backends); if ($fs->lastTreeNo<0) { print STDERR "$f: empty or corrupt file!\n"; next; } $fs->changeBackend($backend); my $out=$f; $out=~s/$opt_s$/$opt_a/ if ($opt_s or $opt_a); $out=~s/^$opt_p/$opt_r/ if ($opt_p or $opt_r); if ($f eq $out) { unlink "$f~" if (-e "$f~" ); # silly MS OSs need this rename $f, "$f~" || die "Cannot create backup file named $f~ for $f\n"; } if ($opt_T) { $fs->changePatterns('${trlemma}', '${func}'); $fs->changeHint('form:'."\t".'${form}'."\n". "afun:\t\${afun}\ntag:\t\${tag}". ''); } $fs->writeFile($out); undef $fs; }