Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Tue, 5 Aug 2003 12:54:43 -0400 (EDT) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: Francis Harvey cc: cygwin AT cygwin DOT com Subject: Re: Install 1.3.22-1 problem - default text file type - DOS In-Reply-To: <9B501B3774931C469BCCCC021BE5372277AD54@remailnt2-re01.westat.com> Message-ID: Importance: Normal MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Tue, 5 Aug 2003, Francis Harvey wrote: > Greetings, > > When installing 1.3.22-1 on XP, I select DOS as the default text file > type. Unfortunately, the packages I use, flex and gcc, don't appear > to correspond to this setting. For gcc, I wrote this program: > > #include > int main() { > char *token; > token = "\n"; > printf("token[0] = %d; token[1] = %d\n",token[0],token[1]); > return 0; > } > > which gives me 10 and 0 when I expected 13 and 10. Also, in flex, > all of my patterns were broken until I substituted the octal values > \015 and \012 for \n. Since this appears in more than one package > and my previous version of Cygwin, 1.1.7, worked correctly with > older versions of these packages, I believe there may been an > installation problem with this latest version, but I don't know how > to test this, let alone fix it. I am thinking of trying my old > installation on the XP to see if that will fix the problems I am > having with the newer versions. I welcome any suggestions. TIA. > > Francis R. Harvey III Francis, I think you misunderstood what the "text" (or DOS) mode means. Mounting in the "text" mode allows the files *on disk* to have the "\r\n" newline sequence which will be translated to "\n" upon reading the file in default mode (i.e., make the default mode "text"), and the reverse translation would happen on writing. Mounting in binary mode does not perform any character translation for default open()s, so you'll actually see the "\r" characters in your program. Of course, you can always override this setting with "rt" for text and "rb" for binary... What your program is doing is something completely different. The C language specification says that the '\n' character represents the ASCII value of NL, or 10. The '\r' character represents the ASCII value of CR, or 13. This won't ever be changed by the mount mode (or the "binmode" setting in the CYGWIN variable). The mount mode only affects interaction with disk files (just like "binmode" affects interaction with pipes). Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "I have since come to realize that being between your mentor and his route to the bathroom is a major career booster." -- Patrick Naughton -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/