Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com Message-Id: <4.2.0.58.20000516152414.01cb76b0@mail.pacific.net> X-Sender: techaven AT mail DOT jps DOT net (Unverified) X-Mailer: QUALCOMM Windows Eudora Pro Version 4.2.0.58 Date: Tue, 16 May 2000 15:35:50 -0700 To: "Larry Hall (RFK Partners, Inc)" From: John Buffington Subject: Re: Problem with CR-LF sensitivity Cc: cygwin AT sourceware DOT cygnus DOT com In-Reply-To: <4.3.1.2.20000516175811.00e2c3e0@pop.ma.ultranet.com> References: <200005162139 DOT RAA07331 AT gtei2 DOT bellatlantic DOT net> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Been doing a lot of translation with tr lately, so this is fresh in my mind. I'm sure Larry knows this, but for the benefit of others, here's my favorite tr commands. tr \\n\\r \\n Translates a dos file on stdin to a unix file on stdout tr \\n \\n\\r Does the inverse tr \\r \\n Translates a mac file to unix tr \\n \\r Does the inverse tr \\r \\n\\r Translates a mac file to a dos file tr \\n\\r \\r Does the inverse --jbuff At 06:00 PM 5/16/00 -0500, you wrote: >There's also versions of dos2unix out there that will do this same thing. >tr, which comes with the distribution, will allow you to generate a file >without carriage returns, given a file as input with them too. Both options >do something similar to the program provided below. > >Larry > > >At 04:39 PM 5/16/00, Mark Schoenberg wrote: > >Xandy, > > > > I too had tremendous problems with the change in the CR/LF > paradigm with > >1.1.0 as compared to B20.1. I wrote a small program, reproduced below, > which > >strips the CRs from files and solved most of the problems. A problem that > >remained for me was that emacs, which I was using, would put CRs in > files and > >not tell you. If you are really interested, I can tell you how to solve the > >emacs problem as well. > > > > Having struggled, like you, I think it is worthwhile upgrading to > 1.1.0. > >If you don't wish to, I found it pretty easy (in Windows 98) to go get > rid of > >1.1.0 by going to "Start"/"Programs"/"Cynus Solutions"/"Uninstall Cygwin > >1.1.0". That seemed to work pretty well. Believe me, I did it at least > twice > >before becoming convinced 1.1 was worth it. I only succeeded in installing > >1.1.0 when I chose \ as the root directory. I suspect choosing other root > >directories is possible, but I couldn't figure how to succeed without > choosing > >\. > > > > The program below for stripping CRs won't work for you as is, > because it > >uses stuff only I have, like /u/local/include/stdhdr.h and getans, but it > >should be able to be easily modified. stdhdr.h simply includes the > necessary > >system header (.h) files, and getans(a, b) simply gets the answer to > question a > >and stores it as string b. > > > > The only significant aspect to the program is the binary read of an > input > >file (note the setmode instruction), and the binary write of an output > file of > >all characters except CR, '\015'. > > > > I am sure there are more sophisticated solutions but this worked for a > >dummy like me. > > > >#include "/u/local/include/stdhdr.h" > >#include > > > >int fileoncom, argn, f1, f2, n, c; > >FILE *ip,*ip2,*fp,*fopen(); > >char filnam[80], outfil[80], buf[1]; > > > >main(argc,argv) > > int argc; > > char **argv; > >{ > > > > getans("Input filename?:",filnam); > > if ((f1=open(filnam, O_RDONLY, 0)) == -1) { > > perror("!stripcr2: Can't open input file!"); > > exit (-1); > > } > > setmode(f1,O_BINARY); > > > > getans("Ouput filename?:",outfil); > > if ((f2=open(outfil, O_CREAT | O_WRONLY | O_TRUNC, 0644)) == -1) { > > perror("!stripcr2: Can't open output file!"); > > exit (-1); > > } > > setmode(f2,O_BINARY); > > > > > > > > while ((n = read(f1 ,buf, 1)) > 0) { /* Binary read, 1 char at a > time > buf */ > > c = *buf; > > // printf("MSDEBUG c = %d\n",c); > > if (c != '\015') write(f2,buf,1); > > } > > close(f1); > > close(f2); > >} > > > > > > > >-- > >Want to unsubscribe from this list? > >Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com > > > >-- >Want to unsubscribe from this list? >Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com -- Want to unsubscribe from this list? Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com