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";
25 $new_version = `mktemp "$TMP/zz_strip_cr_tmp.XXXXXX"`;
28 foreach $filename (&glob_list(@ARGV)) {
29 # go through each file on the command line.
31 open(IN_FILE, "<$filename");
33 open(NEW_FILE, ">$new_version"); # open our temporary file for appending.
36 local($changed_file) = 0; # record if we made any changes.
38 # go through each line in the current file...
39 while ($to_strip_cr = <IN_FILE>) {
42 for ($i = 0; $i < length($to_strip_cr); $i++) {
43 $curr_char = substr($to_strip_cr, $i, 1);
44 if ($curr_char =~ /[\r\n]/) {
45 if ($curr_char =~ /\r/) {
46 # if CR came first, this is a dos style file.
51 $new_line .= $curr_char;
55 # add on unix EOL, just a line feed.
58 print NEW_FILE "$new_line"; # write out the current line.
66 open(NEW, "<$new_version");
67 open(CURR, ">$filename");
68 while (<NEW>) { print CURR; }
73 # clean up our temporaries.
74 unlink("$new_version");