3 ###############################################################################
6 # Author : Chris Koeritz #
7 # Rights : Copyright (C) 1996-$now by Author #
11 # Turns DOS format text files into Unix format text files. #
13 ###############################################################################
14 # This program is free software; you can redistribute it and/or modify it #
15 # under the terms of the GNU General Public License as published by the Free #
16 # Software Foundation; either version 2 of the License, or (at your option) #
17 # any later version. See: "http://www.gruntose.com/Info/GNU/GPL.html" for a #
18 # version of the License. Please send any updates to "fred@gruntose.com". #
19 ###############################################################################
21 require "filename_helper.pl";
22 require "importenv.pl";
24 $new_version = `mktemp "$TMP/zz_strip_cr_tmp.XXXXXX"`;
27 foreach $filename (&glob_list(@ARGV)) {
28 # go through each file on the command line.
30 open(IN_FILE, "<$filename");
32 open(NEW_FILE, ">$new_version"); # open our temporary file for appending.
35 local($changed_file) = 0; # record if we made any changes.
37 # go through each line in the current file...
38 while ($to_strip_cr = <IN_FILE>) {
41 for ($i = 0; $i < length($to_strip_cr); $i++) {
42 $curr_char = substr($to_strip_cr, $i, 1);
43 if ($curr_char =~ /[\r\n]/) {
44 if ($curr_char =~ /\r/) {
45 # if CR came first, this is a dos style file.
50 $new_line .= $curr_char;
54 # add on unix EOL, just a line feed.
57 print NEW_FILE "$new_line"; # write out the current line.
65 open(NEW, "<$new_version");
66 open(CURR, ">$filename");
67 while (<NEW>) { print CURR; }
72 # clean up our temporaries.
73 unlink("$new_version");