home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
-
- #
- # conv.pl
- #
- # Copyright (C) 1996 Johannes Plass
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 2 of the License, or
- # (at your option) any later version.
- #
- # This program is distributed in the hope that it will be useful,
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- # GNU General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program; if not, write to the Free Software
- # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- #
- # Author: Johannes Plass (plass@dipmza.physik.uni-mainz.de)
- #
-
- $addcr=0; # strip cr by default
- if ($ARGV[0] =~ /.*dos/) { $addcr=1; }
-
- $qc_files = "*.qc *.qh progs.src progdefs.h";
- $listfile="sources.list";
- unlink($listfile);
- system("ls -1 $qc_files > $listfile");
- open (LISTFILE, "<" . $listfile) || die "no list of files";
- while ($srcfile=<LISTFILE>) {
- chop $srcfile;
- $destfile = "$srcfile.tmp";
- if ($addcr) { print("Adding CR to $srcfile.\n"); }
- else { print("Stripping CR from $srcfile.\n"); }
- unlink($destfile);
- open (DESTFILE, ">" . "$destfile") || die "cannot open destfile";
- if (open (SRCFILE, "<" . "$srcfile") || die "cannot open srcfile") {
- while ($line = <SRCFILE>) {
- if ($addcr) {
- if ($line =~ /^.*[^\r]$/) { $line =~ s/^(.*)$/$1\r/; }
- } else {
- if ($line =~ /^.*\r+$/) { $line =~ s/^(.*?)\r+$/$1/; }
- }
- print DESTFILE $line;
- }
- }
- close SRCFILE;
- close DESTFILE;
- system("mv $destfile $srcfile");
- }
- close LISTFILE;
- unlink($listfile);
-