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/04 Message-ID: <35C7A9C0.267@ibm.net>#1/1 X-Deja-AN: 377994640 Content-Transfer-Encoding: 7bit References: <35C73769.9BC50362@sandia.gov> Content-Type: text/plain; charset=us-ascii Organization: None Mime-Version: 1.0 Reply-To: pgunn01@ibm.net Newsgroups: comp.sys.dec Anji Morris wrote: > > Hi, > > I am running Digital Unix (OSF1 alf.sandia.gov V4.0 878 alpha). I > cannot seem to find a basic utility that comes with most installations > of unix to convert carriage return/line feeds to new lines (ie. dos2ux, > dos2unix, dtox). Any ideas? Fortunately, it's fairly trivial to write such programs. Something along the lines of the following should do the trick. Note that this is just off the top of my head, and might not work without a bit of debugging. #include #include #define CHAR1 '\r' /* This is the one I'm not sure about. DOS text files use both CR and NL to indicate end of line. I think Unix only uses newlines... */ int main(int argc, char *argv[]) { FILE *ifile, *ofile; int mychar; if(argc != 3) { printf("\nUsage: mytranslater infile outfile\n"); exit(1); } ifile = fopen(argv[1],"rb"); /* Open our input file */ if(ifile == NULL) { printf("Cannot open file %s: error %d\n", argv[1], errno); exit(1); } ofile = fopen(argv[2],"wb+"); /* Open our output file */ if(ofile == NULL) { printf("Cannot open file %s: error %d\n", argv[2], errno); exit(1); } while(mychar = fgetc(ifile)) { if(mychar == EOF) break; if(mychar == 'CHAR1') continue; /* Diddle with logic here to go the other way */ fputc(ofile,mychar); } fclose(ofile); fclose(ifile); exit(1); } -- --------------------------------------------------- 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 ------------------------------------------------