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: wilson@dbit.com (John Wilson) Subject: Re: dos 2 unix Date: 1998/08/04 Message-ID: <35c7b60f.0@news.wizvax.net>#1/1 X-Deja-AN: 378007650 References: <35C73769.9BC50362@sandia.gov> <35C7A9C0.267@ibm.net> X-Trace: 4 Aug 1998 21:31:59 -0500, dbit.dbit.com Organization: D Bit, Troy, NY Newsgroups: comp.sys.dec 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. John Wilson D Bit