delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/10/16/19:05:50

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Wed, 16 Oct 2002 19:07:01 -0400
From: Christopher Faylor <cgf AT redhat DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: starting a cygwin app from a Windows Service
Message-ID: <20021016230701.GB25022@redhat.com>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <9532AC3F9163F4458A2A212C4CF8A2EC2C9508 AT liilmtst03 DOT mailtask DOT com> <CHEDKHJJDLOCCOFLMGEAKENLCNAA DOT dvasaru AT broadpark DOT no>
Mime-Version: 1.0
In-Reply-To: <CHEDKHJJDLOCCOFLMGEAKENLCNAA.dvasaru@broadpark.no>
User-Agent: Mutt/1.4i

On Thu, Oct 17, 2002 at 12:09:35AM +0200, Dan Vasaru wrote:
>Mark,
>
>As Chris suggested, if you want consistent behaviour under cygwin, always
>open text files in text mode (O_TEXT or "rt").
>Even better, wrt portability to Unix platforms, is to:
>
>1. open the file in binary mode
>2. be prepared to accept both CRLF- and LF-style text files (i.e. strip the
>CR yourself)
>
>This way, your software will always "behave" when encountering a Windows
>file while running on a Unix platform.

I don't know.  I think it would be far simpler to have something like:

#ifdef __CYGWIN__
# define READTEXT "rt"
#else
# define READTEXT "r"
#endif

.
.
.

  FILE fp = fopen ("foo", READTEXT);

rather than reinvent the CRLF handling that already exists in the cygwin DLL.

Another option is to link with /usr/lib/automode.o or /usr/lib/textmode.o .

cgf

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019