From: wilson@dbit.com (John Wilson)
Subject: Re: dos 2 unix
Date: 1998/08/04 [thread overview]
Message-ID: <35c7b60f.0@news.wizvax.net> (raw)
In-Reply-To: 35C7A9C0.267@ibm.net
In article <35C7A9C0.267@ibm.net>, Pat Gunn <pgunn01@ibm.net> wrote:
>#define CHAR1 '\r' /* This is the one I'm not sure about.
[...]
>while(mychar = fgetc(ifile))
> {
> if(mychar == EOF)
> break;
> if(mychar == 'CHAR1')
> continue; /* Diddle with logic here to go the other way */
> fputc(ofile,mychar);
> }
Careful, you've fallen victim to the common misconception (unfortunately
shared by C-Kermit) that converting from a regular ASCII file to a UNIX text
file requires removing *all* CRs, whereas in fact you only want to remove
CRs that immediately preceed LFs. This program will screw up files that
use CR for overprinting.
I've got a couple of quicky DOS programs to do the conversion correctly at
http://www.dbit.com/pub/ibmpc/util/addcr.com and .../remcr.com, unfortunately
they're filters so they're a bit cumbersome to use, but anyway the above
program would work if you searched for a CR/LF sequence and replaced *that*
with just LF -- so when you see a CR, set a flag instead of writing (or not
writing) anything out, and then next time through the loop, check the flag
and write the CR out after all if the current char is not LF (then clear
the flag, either way). Ah, also get rid of the single quotes around CHAR1.
John Wilson
D Bit
next prev parent reply other threads:[~1998-08-04 4:00 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-08-04 4:00 dos 2 unix Anji Morris
1998-08-04 4:00 ` Pat Gunn
1998-08-04 4:00 ` John Wilson [this message]
1998-08-08 4:00 ` Pat Gunn
1998-08-04 4:00 ` Stephen Thompson
1998-08-04 4:00 ` Nick Manka
1998-08-06 4:00 ` Hans Schwengeler
1998-08-07 4:00 ` dos 2 unix (Try "flip") Jeff Sullivan
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox