Max wrote:
I’ve downloaded .tar.gz files and uncompressed them to
the windows partition using winzip. Then I’ve copied
them to the linux partition, but it seems winzip has
somehow altered files, so it didn’t work. When I
uncompressed them again from .tar.gz, it worked fine.
Welcome to the CR/LF club! I use a utility to convert the CR/LF pairs in my
ASCII files (don’t convert the binaries before I reboot into Linux. GCC
seems to have no problem but shell scripts are extremely sensitive to
carriage returns.
Just a little hard won safety-tip,
Even though GCC ignores spurious carrage-returns (it treats them as white
space), GCC can still have some trouble with DOS style end-of-line
indicators. Consider the following source code:
#define SomeMacro(x) do (DoSomething(x);
DoSomethingElse(x);
) while (0)
If you don’t convert CR/LF into plain LF for Linux GCC, this gives weird
errors, because the “” line continuation character is no longer the last
character on the line (as is required for it to join lines).
If you are using a “DOS aware” editor that hides the “^M” after the slash,
then the errors can seem quite perplexing.
If you use “unzip” to unzip .zip files under Linux, you can try the "-a"
option to automatically remove the ^M from text files (but keep a keen eye
for binary files that can be [rarely] mis-identified as text).
If you use tar, then its up to you to convert the text files.
One easy way to remove carrage returns from a (single) text file under
unix:
tr --delete ‘\r’ <dosfile_in.txt >unixfile_out.txt
This can get tedious on a directory full of source code, so you can try
something like this little script (which will convert any .c or .h file in
the current directory):
------cut------
#! /bin/sh
for f in *.[ch] ;
do
mv $f orig_$f
tr -d ‘\r’ <orig_$f >$f
done
------cut------
Like byte-order (big-endian vs little-endian), the end of line character
is a little detail, that can sometimes turn out to be a big pain.
Take it easy,
Xark
P.S. No doubt there are probably a few hundred other utilities that can
also do this (better) on freshmeat. :)On Sat, 17 Mar 2001, Randi J. Relander wrote: