From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,10af2d0eb2640809 X-Google-Attributes: gid1164f8,public From: Pat Gunn Subject: Re: dos 2 unix Date: 1998/08/08 Message-ID: <35CC8669.25F@ibm.net>#1/1 X-Deja-AN: 379188050 Content-Transfer-Encoding: 7bit References: <35C73769.9BC50362@sandia.gov> <35C7A9C0.267@ibm.net> <35c7b60f.0@news.wizvax.net> Content-Type: text/plain; charset=us-ascii Organization: None Mime-Version: 1.0 Reply-To: pgunn01@ibm.net Newsgroups: comp.sys.dec John Wilson wrote: > > In article <35C7A9C0.267@ibm.net>, Pat Gunn 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 ------------------------------------------------