From: Pat Gunn <pgunn01@ibm.net>
Subject: Re: dos 2 unix
Date: 1998/08/08 [thread overview]
Message-ID: <35CC8669.25F@ibm.net> (raw)
In-Reply-To: 35c7b60f.0@news.wizvax.net
John Wilson wrote:
>
> 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.
Overprinting? Hmm... Oh well, I guess it could easily be fixed by
making a flag like LCwasLF.. hmm... Let's see... Oh well. Looks like
you didn't quote the whole thing, and I'm too lazy to go back and
fix it from my previous :) I'll just leave it as an activity
for the reader... Algorythmically, you'd just stick in a
#define LF '\whatever the octal for this is'
short LCwasLF = 0;
At the start, and stick in a
if(mychar == 'LF') {LCwasLF = 1; continue;}
and change
if(mychar == 'CHAR1'){continue;}
to
if((mychar == 'CHAR1') && (LCwasLF) ){LCwasLF = 0;continue;}
and plunk a LCwasLF below that.
--
---------------------------------------------------
Pat Gunn, moderator:comp.sys.newton.announce
comoderator:comp.os.os2.moderated
"You can always judge a man by the quality of his enemies." -- Dr Who
http://junior.apk.net/~qc
------------------------------------------------
next prev parent reply other threads:[~1998-08-08 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
1998-08-08 4:00 ` Pat Gunn [this message]
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