This is the mail archive of the cygwin@cygwin.com 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: CR/NL problem with cpp.exe


Kris,

I am no authority on the matter, but I believe most Cygwin/Win32 ports of
"text-based" utilities deal with CRLF/LF by setting the O_TEXT flag and
letting the (C) runtime translate the line endings for them.

Instead of adjusting the file input mode, please note that you may want to
adjust your preprocessor lexer to accept both styles of line endings.
What happens the day you will want to port your CPP to a true Unix, and will
get a DOS file as an input ? Unix will blissfully ignore the O_TEXT flag in
open() calls, and you'll have CR on your input pipe.

GREP is an example of a utility that *doesn't* use O_TEXT, and still handles
all styles of line terminations gracefully. At least in principle.

Dan.

-----Original Message-----
From: cygwin-owner@cygwin.com [mailto:cygwin-owner@cygwin.com]On Behalf
Of Kris Warkentin
Sent: Tuesday, October 01, 2002 10:26 PM
To: Dan Vasaru; cygwin@cygwin.com
Subject: Re: CR/NL problem with cpp.exe


I'm actually quite certain that what you wrote would help.  The issue is
that cccp.c (the gcc preprocessor) does not do that and, as near as I can
tell from the FAQ, shouldn't need to.  That, however, is where I might be
wrong.  I'm wondering if the cpp shipped with Cygwin has been patched so
that it does explicitly open files as text.  If that's the case, then that
might explain why I'm seeing different behaviour.

Aha!  I just copied dosfile.c to a text mode partition and it works with our
preprocessor.  That implies that there must be some buggery in the Cygwin
version of cpp.exe.  I noticed that the version of gcc shipped with cygwin
is 2.95.3-5.  Is the '-5' some form of Cygwin specific patch with some
assorted magic in it?  Perhaps someone on this list would know.

cheers,

Kris

----- Original Message -----
From: "Dan Vasaru" <dvasaru@broadpark.no>
To: "Kris Warkentin" <kewarken@qnx.com>
Sent: Tuesday, October 01, 2002 4:18 PM
Subject: RE: CR/NL problem with cpp.exe


> Sorry about that, I set out to write a longer reply (which I posted to the
> group) and typed CTRL+ENTER just as I got started.
>
> If what I wrote to the group doesn't help, (opening your files with
O_TEXT,
> and setting stdin to textmode), then I believe you have a problem.
> 1. What type are your mounts (where your c files reside)
> 2. What is the value of the CYGWIN variable ?
>
> Dan
> -----Original Message-----
> From: Kris Warkentin [mailto:kewarken@qnx.com]
> Sent: Tuesday, October 01, 2002 10:04 PM
> To: Dan Vasaru
> Subject: Re: CR/NL problem with cpp.exe
>
>
> ----- Original Message -----
> From: "Dan Vasaru" <dvasaru@broadpark.no>
> To: "Kris Warkentin" <kewarken@qnx.com>
> Sent: Tuesday, October 01, 2002 3:48 PM
> Subject: RE: CR/NL problem with cpp.exe
>
>
> > Kris,
> >
> > Please refer to this section of the FAQ:
> >
>
> Which section?  I've read the CR/NL sections of the FAQ and I believe I
> understand the issue at hand.
>
> 1) Two versions of cpp.exe, both compiled under cygwin, both running under
> same environment with the same input from the same filesystem.
> 2) The code for cpp.exe doesn't do anything special but rather just checks
> for '\\' '\n' at the end of a line.
> 3) The cpp.exe shipped with Cygwin works fine - input translation takes
> place just as the FAQ states - the open() call opens them in O_TEXT mode.
> 4) The cpp.exe that we built does not get the benefit of this input
> translation.
>
> As near as I can tell, our cpp.exe should 'just work' and yet it doesn't.
> Any suggestions?
>
> cheers,
>
> Kris
>
>


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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