Install 1.3.22-1 problem - default text file type - DOS

Igor Pechtchanski pechtcha@cs.nyu.edu
Tue Aug 5 16:59:00 GMT 2003


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 <stdio.h>
> 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@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.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/



More information about the Cygwin mailing list