This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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

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


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).
      |\      _,,,---,,_
ZZZzz /,`.-'`'    -.  ;-;;,_
     |,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:
Problem reports:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]