Originally posted by Kaydell Leavitt:
I imagine that the problem might be that DOS/Windows uses a carriage-return and a line-feed to terminate a line and Unix (including Mac OS X which I''m using), uses a single line-feed to terminate each line.
I don't think that's the problem, but unfortunately I don't know what the solution is.
I created a simple "Hello, world" program on my Mac, and forced it to be in DOS text format.
When I edit the source file using "vim Hello.java", I get:
So I can see on the status line that it recognized this as a DOS file and did an auto-convert for me.
If I forcibly tell vim not to auto-convert for me by typing "vim -b Hello.java", I get:
Now I can see a representation of all the carriage returns (the ^M which corresponds to ctrl-M) at the end of each line.
More importantly, when I load this DOS file into Eclipse on my Mac, it handles the carriage returns perfectly - I see the file single spaced.
Anyway - if the problem was the carriage returns, then you could remove them while in the vi editor by typing ":%s/^M//g" (minus the quotes of course). To type the control-M, you would actually have to type control-V (to specify that the next character should be used verbose - no translation) and then type control-M).
Alternatively, you could do the same thing from the command line. Something like "sed 's/^M//g' Hello.java > Hello2.java" would do the trick (again, not typing the double quotes). You could easily script this to work with all the files you have to convert rather than do them manually.
Alternatively, if you have
Fink installed, you can use it to easily install the "dosunix" package, which describes itself as:
dosunix
Converts DOS text files to unix text format
Installed:None
Unstable:None
Stable:1.0.13-1
Binary:1.0.13-1
DosUnix is made up of three programs: - dosunix, which creates a copy of a DOS text file
in Unix text format.
- unixdos, which creates a copy of a Unix text file
in DOS text format.
- chktxt, which inspects a given text file to determine
whether it is in DOS text format or Unix text format.
Web site: http://dosunix.sourceforge.net
Maintainer: None <fink-devel@lists.sourceforge.net>
Unfortunately, while I have given a number of solutions to your question of how to convert the files, I doubt that I have solved your problem, as Eclipse should handle the files without problem.
One thing you could try is taking a look at one of the files in byte format. For example:
od provides octal dumps, which personally I find very trying
. Fortunately it does far more than that - for example, the -a flag tells it to still spit everything out byte by byte, but give ascii equivalents for everything. So it is easy for me to visually verify that this file does have both carriage returns and newlines.
Perhaps you could run this command on one of your files and determine what it is that is causing the problem?
Some examples I can think of:
The file is actually double spaced (why, I don't know)The file has mixed formatting - some lines only have line feeds, some have both carriage return and line feed. Most editors wont know what the safe thing to do is in that situation, so they default to assuming you want everything verboseThe file has newlines followed by carriage returns (I think this was old OSX format, or was it VMS - it is too long since I had to deal with that format). Regards, Andrew
[ March 30, 2008: Message edited by: Andrew Monkhouse ]