public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: file descriptors opened as text files
@ 2001-02-15 15:53 Heribert Dahms
  2001-02-15 16:06 ` Larry Hall (RFK Partners, Inc)
  2001-02-16  8:12 ` Ehud Karni
  0 siblings, 2 replies; 36+ messages in thread
From: Heribert Dahms @ 2001-02-15 15:53 UTC (permalink / raw)
  To: 'Larry Hall (RFK Partners Inc)', Jean Delvare, cygwin

Hi Larry,

you forgot about another level of default:

From:	Chris Faylor [cgf@cygnus.com]
Sent:	Friday, July 28, 2000 21:13
To:	cygwin@sources.redhat.com
Subject:	[ANNOUNCEMENT] Updated: Cygwin DLL 1.1.3


- binmode.o and textmode.o files are now available for linking with an
  application to force an application to open files in binmode or
  textmode by default.


Bye, Heribert (heribert_dahms@icon-gmbh.de)

> -----Original Message-----
> From:	Larry Hall (RFK Partners Inc) [SMTP:lhall@rfk.com]
> Sent:	Wednesday, February 14, 2001 23:51
> To:	Jean Delvare; cygwin@cygwin.com
> Subject:	Re: file descriptors opened as text files
> 
> This is the key phrase.  cygwin1.dll is always required.  If you use it,
> it handles your program's interaction with the Windows' system.
> Regardless
> of whether there is an explicit mount point or not, Cygwin controls the
> behavior.  For files, the default treatment is always text, unless a mount
> or the program itself indicates otherwise.
> 

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: file descriptors opened as text files
  2001-02-15 15:53 file descriptors opened as text files Heribert Dahms
@ 2001-02-15 16:06 ` Larry Hall (RFK Partners, Inc)
  2001-02-15 18:26   ` Christopher Faylor
  2001-02-16  8:12 ` Ehud Karni
  1 sibling, 1 reply; 36+ messages in thread
From: Larry Hall (RFK Partners, Inc) @ 2001-02-15 16:06 UTC (permalink / raw)
  To: Heribert Dahms, Jean Delvare, cygwin

Good point.  Thanks for the reminder.


At 06:52 PM 2/15/2001, Heribert Dahms wrote:
>Hi Larry,
>
>you forgot about another level of default:
>
>From:   Chris Faylor [cgf@cygnus.com]
>Sent:   Friday, July 28, 2000 21:13
>To:     cygwin@sources.redhat.com
>Subject:        [ANNOUNCEMENT] Updated: Cygwin DLL 1.1.3
>
>
>- binmode.o and textmode.o files are now available for linking with an
>   application to force an application to open files in binmode or
>   textmode by default.
>
>
>Bye, Heribert (heribert_dahms@icon-gmbh.de)
>
> > -----Original Message-----
> > From: Larry Hall (RFK Partners Inc) [SMTP:lhall@rfk.com]
> > Sent: Wednesday, February 14, 2001 23:51
> > To:   Jean Delvare; cygwin@cygwin.com
> > Subject:      Re: file descriptors opened as text files
> > 
> > This is the key phrase.  cygwin1.dll is always required.  If you use it,
> > it handles your program's interaction with the Windows' system.
> > Regardless
> > of whether there is an explicit mount point or not, Cygwin controls the
> > behavior.  For files, the default treatment is always text, unless a mount
> > or the program itself indicates otherwise.
> > 



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15 16:06 ` Larry Hall (RFK Partners, Inc)
@ 2001-02-15 18:26   ` Christopher Faylor
  0 siblings, 0 replies; 36+ messages in thread
From: Christopher Faylor @ 2001-02-15 18:26 UTC (permalink / raw)
  To: cygwin

On Thu, Feb 15, 2001 at 07:01:43PM -0500, Larry Hall (RFK Partners, Inc) wrote:
>Good point.  Thanks for the reminder.

And, actually, now that I have documentation on the brain, I should document
these somewhere.

Thanks,
cgf

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15 15:53 file descriptors opened as text files Heribert Dahms
  2001-02-15 16:06 ` Larry Hall (RFK Partners, Inc)
@ 2001-02-16  8:12 ` Ehud Karni
  1 sibling, 0 replies; 36+ messages in thread
From: Ehud Karni @ 2001-02-16  8:12 UTC (permalink / raw)
  To: cygwin

On Fri, 16 Feb 2001 00:52:25 +0100, Heribert Dahms <heribert_dahms@icon-gmbh.de> wrote:
> 
> - binmode.o and textmode.o files are now available for linking with an
>   application to force an application to open files in binmode or
>   textmode by default.

Just a clarifying question: Does these o files affects the pre-opened
files/fids (stdin, stdout and stderr - 0, 1 2) ?
If so, is it independent of the piping (i.e. < file, prog | prog ) ?

Ehud.


-- 
 @@@@@@ @@@ @@@@@@ @    @   Ehud Karni  Simon & Wiesel  Insurance agency
     @    @      @  @@  @   Tel: +972-3-6212-757    Fax: +972-3-6292-544
     @    @ @    @ @  @@    (USA)  Fax  and  voice  mail:  1-815-5509341
     @    @ @    @ @    @        Better     Safe     Than     Sorry
 http://www.simonwiesel.co.il    mailto:ehud@unix.simonwiesel.co.il

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* RE: file descriptors opened as text files
  2001-02-15  6:39               ` Jean Delvare
                                   ` (3 preceding siblings ...)
  2001-02-15  8:04                 ` Earnie Boyd
@ 2001-02-15 21:11                 ` Lothan
  4 siblings, 0 replies; 36+ messages in thread
From: Lothan @ 2001-02-15 21:11 UTC (permalink / raw)
  To: Jean Delvare, Larry Hall (RFK Partners Inc); +Cc: cygwin

> From: cygwin-owner@sources.redhat.com
> [ mailto:cygwin-owner@sources.redhat.com]On Behalf Of Jean Delvare
> Sent: Thursday, February 15, 2001 6:37 AM
> To: Larry Hall (RFK Partners Inc)
> Cc: cygwin@sources.redhat.com
> Subject: Re: file descriptors opened as text files
>
> Yes, b is fine when opening a file *handle* with fopen(). But I am working
> with a file *descriptor* returned by open(), which is quite different.
> open()'s behavior is ruled by a bunch of O flags such as O_RDONLY,
> O_WRONLY and so on. Linux's man page for open(2) don't specify any flag
> for text or binary mode. But I grep'ed Cygnus' includes for any O flag
> and I could see that there are O_BINARY and O_TEXT flags defined. Using
> O_BINARY solves my problem, indeed.
>
> Now that everything works for me, I'd like to share my point of view on
> the subject.
>
> Having file handles open the files in text mode as a default behavior
> doesn't sound that bad. It is the way all systems act, and the "b" flag is
> standardized.
>
> But file descriptors being concerned, cygwin's behavior is just weird (my
> opinion). The file desciptor is the lowest access level to the files. In
> the unix world (the real one) there is simply no text mode defined for
> file descriptors (which makes my program using O_BINARY unportable). It
> looks like a Cygnus' invention, and will probably cause lots of trouble to
> any developper porting applications using file descriptors - and there
> must be a lot. I don't even think this behavior is POSIX compliant (but I
> don't know how to check it).

Cygwin's behavior makes perfect sense if you consider all the hoops it has
to go through to maintain compatibility with *nix and POSIX. It attempts to
solve the problem of enabling *nix tools to work as cleanly and easily as
possible in a Windows environment where everything is terminated with CR/LF
line endings. The other possibility is to make binary mode the default and
answer every third question with "Did you strip the CR's from the file
first?" It does not solve every problem with line terminators, of course,
but they are significantly reduced. The O_BINARY and O_TEXT extensions may
or may not be POSIX compliant, but Cygwin is not the only platform that
offers these extensions. Your compatibility concerns are easily handled with
a simple #ifdef __CYGWIN__ around the appropriate code.


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15  9:28                       ` Jean Delvare
  2001-02-15  9:37                         ` Larry Hall (RFK Partners, Inc)
@ 2001-02-15 10:38                         ` Christopher Faylor
  1 sibling, 0 replies; 36+ messages in thread
From: Christopher Faylor @ 2001-02-15 10:38 UTC (permalink / raw)
  To: cygwin

On Thu, Feb 15, 2001 at 06:28:26PM +0100, Jean Delvare wrote:
>
>> Everyone has complained about text/binary modes!:-)  Check the mail archives
>> if you're interested in the details.
>I did it of course, and even before asking anything on the list. I browsed
>back to october 2000 and saw nothing about this specific point. Thus me
>questionning about it (and still wondering how it can be the way it is).

You are delusional, then.  This has been discussed countless times before.

cgf

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15  9:21                   ` Jean Delvare
  2001-02-15  9:24                     ` Larry Hall (RFK Partners, Inc)
@ 2001-02-15 10:37                     ` Christopher Faylor
  1 sibling, 0 replies; 36+ messages in thread
From: Christopher Faylor @ 2001-02-15 10:37 UTC (permalink / raw)
  To: cygwin

On Thu, Feb 15, 2001 at 06:21:08PM +0100, Jean Delvare wrote:
>
>
>> Its not a Cygwin invention.  Its a MS one.  Check out the documentation
>> for open()/_open() on the MSDN.  They use the _O_BINARY flag.  Don't get me
>> wrong.  I hate text mode in all its forms.  Perhaps Cygwin could've forgone
>> its use here.  Maybe not.  However, doing so here follows the MS lead and
>> wasn't a Cygwin concoction.
>I don't use MS development softwares. That's not the point here.

Sorry.  Yes, it is the point here.  Cygwin tries to emulate MSVC with
respect to the binary/text mode stuff.

Unless you can prove some incompatibility, get over it.  It's not going
to change.

cgf

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15  9:12                   ` Jean Delvare
  2001-02-15  9:17                     ` Larry Hall (RFK Partners, Inc)
@ 2001-02-15 10:11                     ` Earnie Boyd
  1 sibling, 0 replies; 36+ messages in thread
From: Earnie Boyd @ 2001-02-15 10:11 UTC (permalink / raw)
  To: Jean Delvare; +Cc: DJ Delorie, lhall, cygwin

Jean Delvare wrote:
> 
> Whaou, DJ Delorie writing to me :)
> 
> > The best way to make this portable is to do this:
> >
> > #include <fcntl.h>
> > #ifndef O_BINARY
> > #define O_BINARY 0
> > #endif
> 
> Of course it is. And of course it is what I did :)
> I'm not complaining for myself anymore, now I know how to handle the
> problem. But I thing there is something terribly weird there, and I
> believe it will cause unrequired problem to many developpers. Am I really
> the first one to complain about this here ?
> 

As I stated earlier, this is a technological standard.  Stop belly
aching here about it as there is nothing that can be done.

Earnie.

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15  9:28                       ` Jean Delvare
@ 2001-02-15  9:37                         ` Larry Hall (RFK Partners, Inc)
  2001-02-15 10:38                         ` Christopher Faylor
  1 sibling, 0 replies; 36+ messages in thread
From: Larry Hall (RFK Partners, Inc) @ 2001-02-15  9:37 UTC (permalink / raw)
  To: Jean Delvare; +Cc: DJ Delorie, cygwin

At 12:28 PM 2/15/2001, Jean Delvare wrote:

> > Everyone has complained about text/binary modes!:-)  Check the mail archives
> > if you're interested in the details.
>I did it of course, and even before asking anything on the list. I browsed
>back to october 2000 and saw nothing about this specific point. Thus me
>questionning about it (and still wondering how it can be the way it is).



October 2000?  Why didn't you search the whole archives?  How young do you 
think this project is?  Personally, I'm relieved that this topic has not 
flared up (again) in that time period!:-)  Search the WHOLE archives.  Also,
if you don't like what you find either before or after that, submit a patch 
and it will be considered.



  

Larry Hall                              lhall@rfk.com
RFK Partners, Inc.                      http://www.rfk.com
118 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15  8:04                 ` Earnie Boyd
@ 2001-02-15  9:30                   ` Jean Delvare
  0 siblings, 0 replies; 36+ messages in thread
From: Jean Delvare @ 2001-02-15  9:30 UTC (permalink / raw)
  To: Earnie Boyd; +Cc: Larry Hall (RFK Partners Inc), cygwin

> Feel free to post patches.
Well, I better feel free to take my exams now :/
If it's not fixed when I'm over them (and hopefully pass them) I'll have a
look.


-- 
       /~~       Jean "Khali" Delvare
  -----\_                        mail: delvare@ensicaen.ismra.fr
 --------\                http://www.ensicaen.ismra.fr/~delvare/
---=ISMRA/- ____________________________________________________


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15  9:17                     ` Larry Hall (RFK Partners, Inc)
@ 2001-02-15  9:28                       ` Jean Delvare
  2001-02-15  9:37                         ` Larry Hall (RFK Partners, Inc)
  2001-02-15 10:38                         ` Christopher Faylor
  0 siblings, 2 replies; 36+ messages in thread
From: Jean Delvare @ 2001-02-15  9:28 UTC (permalink / raw)
  To: Larry Hall (RFK Partners, Inc); +Cc: DJ Delorie, cygwin

> Everyone has complained about text/binary modes!:-)  Check the mail archives
> if you're interested in the details.
I did it of course, and even before asking anything on the list. I browsed
back to october 2000 and saw nothing about this specific point. Thus me
questionning about it (and still wondering how it can be the way it is).


-- 
       /~~       Jean "Khali" Delvare
  -----\_                        mail: delvare@ensicaen.ismra.fr
 --------\                http://www.ensicaen.ismra.fr/~delvare/
---=ISMRA/- ____________________________________________________


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15  9:21                   ` Jean Delvare
@ 2001-02-15  9:24                     ` Larry Hall (RFK Partners, Inc)
  2001-02-15 10:37                     ` Christopher Faylor
  1 sibling, 0 replies; 36+ messages in thread
From: Larry Hall (RFK Partners, Inc) @ 2001-02-15  9:24 UTC (permalink / raw)
  To: Jean Delvare; +Cc: cygwin

At 12:21 PM 2/15/2001, Jean Delvare wrote:


> > Its not a Cygwin invention.  Its a MS one.  Check out the documentation
> > for open()/_open() on the MSDN.  They use the _O_BINARY flag.  Don't get me
> > wrong.  I hate text mode in all its forms.  Perhaps Cygwin could've forgone
> > its use here.  Maybe not.  However, doing so here follows the MS lead and
> > wasn't a Cygwin concoction.
>I don't use MS development softwares. That's not the point here. Cygwin
>intends to provide an environment for fast port from Unix to Windows, so
>what it must look and behave like is Unix, not Windows. And the fast if,
>O_BINARY and O_TEXT are not defined on Unix systems. Moreover, a file
>descriptor is always working in binary mode on Unix. Thus, the choice
>Cygwin made here will necessary cause problems to anyone porting a
>software using file descriptors, and there must (and will) be thousands,
>for sure.
>
>I strongly believe that the correct behavior would be to consider any file
>descriptor as binary. People needing higher lever control are supposed to
>use handles anyway, not descriptors.


Feel free to start another binary vs text file debate/war but for the sanity
of all on this list that have lived through it many times before here, take 
it up on another list.

Thanks,



Larry Hall                              lhall@rfk.com
RFK Partners, Inc.                      http://www.rfk.com
118 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15  7:54                 ` Larry Hall (RFK Partners, Inc)
@ 2001-02-15  9:21                   ` Jean Delvare
  2001-02-15  9:24                     ` Larry Hall (RFK Partners, Inc)
  2001-02-15 10:37                     ` Christopher Faylor
  0 siblings, 2 replies; 36+ messages in thread
From: Jean Delvare @ 2001-02-15  9:21 UTC (permalink / raw)
  To: Larry Hall (RFK Partners, Inc); +Cc: cygwin

> Its not a Cygwin invention.  Its a MS one.  Check out the documentation
> for open()/_open() on the MSDN.  They use the _O_BINARY flag.  Don't get me
> wrong.  I hate text mode in all its forms.  Perhaps Cygwin could've forgone
> its use here.  Maybe not.  However, doing so here follows the MS lead and
> wasn't a Cygwin concoction.
I don't use MS development softwares. That's not the point here. Cygwin
intends to provide an environment for fast port from Unix to Windows, so
what it must look and behave like is Unix, not Windows. And the fast if,
O_BINARY and O_TEXT are not defined on Unix systems. Moreover, a file
descriptor is always working in binary mode on Unix. Thus, the choice
Cygwin made here will necessary cause problems to anyone porting a
software using file descriptors, and there must (and will) be thousands,
for sure.

I strongly believe that the correct behavior would be to consider any file
descriptor as binary. People needing higher lever control are supposed to
use handles anyway, not descriptors.


-- 
       /~~       Jean "Khali" Delvare
  -----\_                        mail: delvare@ensicaen.ismra.fr
 --------\                http://www.ensicaen.ismra.fr/~delvare/
---=ISMRA/- ____________________________________________________


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15  9:12                   ` Jean Delvare
@ 2001-02-15  9:17                     ` Larry Hall (RFK Partners, Inc)
  2001-02-15  9:28                       ` Jean Delvare
  2001-02-15 10:11                     ` Earnie Boyd
  1 sibling, 1 reply; 36+ messages in thread
From: Larry Hall (RFK Partners, Inc) @ 2001-02-15  9:17 UTC (permalink / raw)
  To: Jean Delvare, DJ Delorie; +Cc: cygwin

At 12:12 PM 2/15/2001, Jean Delvare wrote:
>believe it will cause unrequired problem to many developpers. Am I really
>the first one to complain about this here ?


Everyone has complained about text/binary modes!:-)  Check the mail archives
if you're interested in the details.


Larry Hall                              lhall@rfk.com
RFK Partners, Inc.                      http://www.rfk.com
118 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15  7:59                 ` DJ Delorie
@ 2001-02-15  9:12                   ` Jean Delvare
  2001-02-15  9:17                     ` Larry Hall (RFK Partners, Inc)
  2001-02-15 10:11                     ` Earnie Boyd
  0 siblings, 2 replies; 36+ messages in thread
From: Jean Delvare @ 2001-02-15  9:12 UTC (permalink / raw)
  To: DJ Delorie; +Cc: lhall, cygwin

Whaou, DJ Delorie writing to me :)

> The best way to make this portable is to do this:
> 
> #include <fcntl.h>
> #ifndef O_BINARY
> #define O_BINARY 0
> #endif

Of course it is. And of course it is what I did :)
I'm not complaining for myself anymore, now I know how to handle the
problem. But I thing there is something terribly weird there, and I
believe it will cause unrequired problem to many developpers. Am I really
the first one to complain about this here ?

Arguments follow.

Thanks anyway :)


-- 
       /~~       Jean "Khali" Delvare
  -----\_                        mail: delvare@ensicaen.ismra.fr
 --------\                http://www.ensicaen.ismra.fr/~delvare/
---=ISMRA/- ____________________________________________________


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15  6:39               ` Jean Delvare
                                   ` (2 preceding siblings ...)
  2001-02-15  8:04                 ` Corinna Vinschen
@ 2001-02-15  8:04                 ` Earnie Boyd
  2001-02-15  9:30                   ` Jean Delvare
  2001-02-15 21:11                 ` Lothan
  4 siblings, 1 reply; 36+ messages in thread
From: Earnie Boyd @ 2001-02-15  8:04 UTC (permalink / raw)
  To: Jean Delvare; +Cc: Larry Hall (RFK Partners Inc), cygwin

Jean Delvare wrote:
> 
> > Said it before but I'll say it again.  In the absence of mount points,
> > Cywgin adopts defaults which it will use if it needs to.  That's text mode
> > in this case.
> Agreed.
> 
> > "b" is fine, as you indicated before.  Check the MSDN library at
> > msdn.microsoft.com for one source.  I'm sure you can find this information
> > in any POSIX complaint UNIX API reference.
> Yes, b is fine when opening a file *handle* with fopen(). But I am working
> with a file *descriptor* returned by open(), which is quite different.
> open()'s behavior is ruled by a bunch of O flags such as O_RDONLY,
> O_WRONLY and so on. Linux's man page for open(2) don't specify any flag
> for text or binary mode. But I grep'ed Cygnus' includes for any O flag
> and I could see that there are O_BINARY and O_TEXT flags defined. Using
> O_BINARY solves my problem, indeed.
> 
> Now that everything works for me, I'd like to share my point of view on
> the subject.
> 
> Having file handles open the files in text mode as a default behavior
> doesn't sound that bad. It is the way all systems act, and the "b" flag is
> standardized.
> 
> But file descriptors being concerned, cygwin's behavior is just weird (my
> opinion). The file desciptor is the lowest access level to the files. In
> the unix world (the real one) there is simply no text mode defined for
> file descriptors (which makes my program using O_BINARY unportable). 

It sounds as if you need to do a Google search.  O_BINARY is not a
Cygnus invention as you suppose, it is a technology standard.  The
typical advice for portability using the flag is
  #ifndef O_BINARY
  #define O_BINARY 0
  #endif
and then your program becomes portable to all systems.
> It
> looks like a Cygnus' invention, and will probably cause lots of trouble to
> any developper porting applications using file descriptors - and there
> must be a lot. I don't even think this behavior is POSIX compliant (but I
> don't know how to check it).
> 

Searching the net for information is a great advance in technological
research you should learn to take advantage of it.

> Here it is. Feel free to react ;)
> 
> Another point to be corrected :
> Strip doesn't work as other tools regarding file's .exe extension.
> Consider these lines in a Makefile :
> 
> strip : prog1
>         strip prog1
> 
> Consider we have prog1.exe compiled in the directory. Typing 'make strip'
> won't complain about a missing 'prog1' and understands that it refers to
> 'prog1.exe', but then strip complains that it won't find 'prog1'.
> It really sound like something needing to be corrected, isn't it?
> 

Feel free to post patches.

Earnie.

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15  6:39               ` Jean Delvare
  2001-02-15  7:54                 ` Larry Hall (RFK Partners, Inc)
  2001-02-15  7:59                 ` DJ Delorie
@ 2001-02-15  8:04                 ` Corinna Vinschen
  2001-02-15  8:04                 ` Earnie Boyd
  2001-02-15 21:11                 ` Lothan
  4 siblings, 0 replies; 36+ messages in thread
From: Corinna Vinschen @ 2001-02-15  8:04 UTC (permalink / raw)
  To: cygwin

On Thu, Feb 15, 2001 at 03:36:59PM +0100, Jean Delvare wrote:
> But file descriptors being concerned, cygwin's behavior is just weird (my
> opinion). The file desciptor is the lowest access level to the files. In
> the unix world (the real one) there is simply no text mode defined for
> file descriptors (which makes my program using O_BINARY unportable). It
> looks like a Cygnus' invention, and will probably cause lots of trouble to
> any developper porting applications using file descriptors - and there
> must be a lot. I don't even think this behavior is POSIX compliant (but I
> don't know how to check it).

1st step: Add O_BINARY to the open calls.
2nd step:

	#ifndef O_BINARY
	#define O_BINARY 0
	#endif

Ported (mostly).

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15  6:39               ` Jean Delvare
  2001-02-15  7:54                 ` Larry Hall (RFK Partners, Inc)
@ 2001-02-15  7:59                 ` DJ Delorie
  2001-02-15  9:12                   ` Jean Delvare
  2001-02-15  8:04                 ` Corinna Vinschen
                                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 36+ messages in thread
From: DJ Delorie @ 2001-02-15  7:59 UTC (permalink / raw)
  To: delvare; +Cc: lhall, cygwin

> Yes, b is fine when opening a file *handle* with fopen(). But I am working
> with a file *descriptor* returned by open(), which is quite different.
> open()'s behavior is ruled by a bunch of O flags such as O_RDONLY, 

The best way to make this portable is to do this:

#include <fcntl.h>
#ifndef O_BINARY
#define O_BINARY 0
#endif

Now you can use O_BINARY everywhere, and it will always do the right
thing.  Same for O_TEXT if you need it.

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-15  6:39               ` Jean Delvare
@ 2001-02-15  7:54                 ` Larry Hall (RFK Partners, Inc)
  2001-02-15  9:21                   ` Jean Delvare
  2001-02-15  7:59                 ` DJ Delorie
                                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 36+ messages in thread
From: Larry Hall (RFK Partners, Inc) @ 2001-02-15  7:54 UTC (permalink / raw)
  To: Jean Delvare; +Cc: cygwin

At 09:36 AM 2/15/2001, Jean Delvare wrote:
>But file descriptors being concerned, cygwin's behavior is just weird (my
>opinion). The file desciptor is the lowest access level to the files. In
>the unix world (the real one) there is simply no text mode defined for
>file descriptors (which makes my program using O_BINARY unportable). It
>looks like a Cygnus' invention, and will probably cause lots of trouble to
>any developper porting applications using file descriptors - and there
>must be a lot. I don't even think this behavior is POSIX compliant (but I
>don't know how to check it).


Its not a Cygwin invention.  Its a MS one.  Check out the documentation
for open()/_open() on the MSDN.  They use the _O_BINARY flag.  Don't get me
wrong.  I hate text mode in all its forms.  Perhaps Cygwin could've forgone
its use here.  Maybe not.  However, doing so here follows the MS lead and
wasn't a Cygwin concoction.


Larry Hall                              lhall@rfk.com
RFK Partners, Inc.                      http://www.rfk.com
118 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX



--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 15:00             ` Larry Hall (RFK Partners Inc)
  2001-02-14 16:54               ` Ross Smith
@ 2001-02-15  6:39               ` Jean Delvare
  2001-02-15  7:54                 ` Larry Hall (RFK Partners, Inc)
                                   ` (4 more replies)
  1 sibling, 5 replies; 36+ messages in thread
From: Jean Delvare @ 2001-02-15  6:39 UTC (permalink / raw)
  To: Larry Hall (RFK Partners Inc); +Cc: cygwin

> Said it before but I'll say it again.  In the absence of mount points, 
> Cywgin adopts defaults which it will use if it needs to.  That's text mode
> in this case.
Agreed.

> "b" is fine, as you indicated before.  Check the MSDN library at 
> msdn.microsoft.com for one source.  I'm sure you can find this information
> in any POSIX complaint UNIX API reference.
Yes, b is fine when opening a file *handle* with fopen(). But I am working
with a file *descriptor* returned by open(), which is quite different.
open()'s behavior is ruled by a bunch of O flags such as O_RDONLY, 
O_WRONLY and so on. Linux's man page for open(2) don't specify any flag
for text or binary mode. But I grep'ed Cygnus' includes for any O flag
and I could see that there are O_BINARY and O_TEXT flags defined. Using
O_BINARY solves my problem, indeed.

Now that everything works for me, I'd like to share my point of view on
the subject.

Having file handles open the files in text mode as a default behavior
doesn't sound that bad. It is the way all systems act, and the "b" flag is
standardized.

But file descriptors being concerned, cygwin's behavior is just weird (my
opinion). The file desciptor is the lowest access level to the files. In
the unix world (the real one) there is simply no text mode defined for
file descriptors (which makes my program using O_BINARY unportable). It
looks like a Cygnus' invention, and will probably cause lots of trouble to
any developper porting applications using file descriptors - and there
must be a lot. I don't even think this behavior is POSIX compliant (but I
don't know how to check it).

Here it is. Feel free to react ;)

Another point to be corrected :
Strip doesn't work as other tools regarding file's .exe extension.
Consider these lines in a Makefile :

strip : prog1
	strip prog1

Consider we have prog1.exe compiled in the directory. Typing 'make strip'
won't complain about a missing 'prog1' and understands that it refers to
'prog1.exe', but then strip complains that it won't find 'prog1'.
It really sound like something needing to be corrected, isn't it?

-- 
       /~~       Jean "Khali" Delvare
  -----\_                        mail: delvare@ensicaen.ismra.fr
 --------\                http://www.ensicaen.ismra.fr/~delvare/
---=ISMRA/- ____________________________________________________


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 16:54               ` Ross Smith
  2001-02-14 19:28                 ` Christopher Faylor
@ 2001-02-15  1:36                 ` Jesper Eskilson
  1 sibling, 0 replies; 36+ messages in thread
From: Jesper Eskilson @ 2001-02-15  1:36 UTC (permalink / raw)
  To: Ross Smith; +Cc: cygwin

Ross Smith <ross.s@ihug.co.nz> writes:

> There's no standard way to select the mode for open(), but Cygwin
> provides the non-standard one O_TEXT. Include it in your open mode flags
> (second argument to open()).

All flags to open() are documented in /usr/include/sys/fcntl.h.

/Jesper
-- 
-------------------------------------------------------------------------
Jesper Eskilson                                         jojo@virtutech.se
Virtutech                                         http://www.virtutech.se
-------------------------------------------------------------------------


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 16:54               ` Ross Smith
@ 2001-02-14 19:28                 ` Christopher Faylor
  2001-02-15  1:36                 ` Jesper Eskilson
  1 sibling, 0 replies; 36+ messages in thread
From: Christopher Faylor @ 2001-02-14 19:28 UTC (permalink / raw)
  To: cygwin

On Thu, Feb 15, 2001 at 01:52:31PM +1300, Ross Smith wrote:
>"Larry Hall (RFK Partners Inc)" wrote:
>> 
>> At 05:43 PM 2/14/01, Jean Delvare wrote:
>> 
>> >That may explain why I could not see the flag on linux's man pages. But
>> >there is no man page for open(2) on Cygwin, right ? Then, where am I
>> >supposed to find the value for this flag, if it ever exist ? I can't just
>> >invent it, I guess it won't work ;)
>> 
>> "b" is fine, as you indicated before.  Check the MSDN library at
>> msdn.microsoft.com for one source.  I'm sure you can find this information
>> in any POSIX complaint UNIX API reference.
>
>Possibly not. I don't have a copy of the relevant Posix standard, but
>the Single Unix Standard (which I believe is intended to be a superset
>of Posix) doesn't recognise the binary/text mode distinction.
>
>However, the C standard mandates that fopen() uses text mode by default
>in the absence of the "b" flag, and the C++ standard says the same thing
>about iostreams. So, given that the two higher-level I/O APIs are both
>required to default to text mode, it seems perfectly reasonable to me
>for the lowest-level one, open(), to do the same thing in the absence of
>any standard requirements, and it looks as though the Cygwin designers
>have followed the same reasoning.

I suspect that the main reason for implementing things this way was that
"It works that way with MSVC".  I don't know that anyone really knows
the real reason for this, though.  Maybe it was just a horrible mistake
that has been propagated since the projects inception in 1995.

cgf

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 15:00             ` Larry Hall (RFK Partners Inc)
@ 2001-02-14 16:54               ` Ross Smith
  2001-02-14 19:28                 ` Christopher Faylor
  2001-02-15  1:36                 ` Jesper Eskilson
  2001-02-15  6:39               ` Jean Delvare
  1 sibling, 2 replies; 36+ messages in thread
From: Ross Smith @ 2001-02-14 16:54 UTC (permalink / raw)
  To: cygwin

"Larry Hall (RFK Partners Inc)" wrote:
> 
> At 05:43 PM 2/14/01, Jean Delvare wrote:
> 
> >That may explain why I could not see the flag on linux's man pages. But
> >there is no man page for open(2) on Cygwin, right ? Then, where am I
> >supposed to find the value for this flag, if it ever exist ? I can't just
> >invent it, I guess it won't work ;)
> 
> "b" is fine, as you indicated before.  Check the MSDN library at
> msdn.microsoft.com for one source.  I'm sure you can find this information
> in any POSIX complaint UNIX API reference.

Possibly not. I don't have a copy of the relevant Posix standard, but
the Single Unix Standard (which I believe is intended to be a superset
of Posix) doesn't recognise the binary/text mode distinction.

However, the C standard mandates that fopen() uses text mode by default
in the absence of the "b" flag, and the C++ standard says the same thing
about iostreams. So, given that the two higher-level I/O APIs are both
required to default to text mode, it seems perfectly reasonable to me
for the lowest-level one, open(), to do the same thing in the absence of
any standard requirements, and it looks as though the Cygwin designers
have followed the same reasoning.

There's no standard way to select the mode for open(), but Cygwin
provides the non-standard one O_TEXT. Include it in your open mode flags
(second argument to open()).

-- 
Ross Smith <ross.s@ihug.co.nz> The Internet Group, Auckland, New Zealand
========================================================================
          "Normally he was insane, but he had lucid moments
          when he was merely stupid."     -- Heinrich Heine

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 14:46           ` Jean Delvare
  2001-02-14 15:00             ` Larry Hall (RFK Partners Inc)
@ 2001-02-14 15:04             ` Christopher Faylor
  1 sibling, 0 replies; 36+ messages in thread
From: Christopher Faylor @ 2001-02-14 15:04 UTC (permalink / raw)
  To: cygwin

On Wed, Feb 14, 2001 at 11:43:29PM +0100, Jean Delvare wrote:
>Maybe I could save your time. I feel a bit guilty... Is there a kind of
>reference manual for Cygwin that explain all this ? It doesn't sound that
>evident to me.

The cygwin web page is http://cygwin.com/ .  There is a pretty obvious link
there.

cgf

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 14:46           ` Jean Delvare
@ 2001-02-14 15:00             ` Larry Hall (RFK Partners Inc)
  2001-02-14 16:54               ` Ross Smith
  2001-02-15  6:39               ` Jean Delvare
  2001-02-14 15:04             ` Christopher Faylor
  1 sibling, 2 replies; 36+ messages in thread
From: Larry Hall (RFK Partners Inc) @ 2001-02-14 15:00 UTC (permalink / raw)
  To: Jean Delvare; +Cc: cygwin

At 05:43 PM 2/14/01, Jean Delvare wrote:

>> You proceed from a false supposition.
>Looks like. Be sure I'm doing my best to understand, anyway.
>
>> mount is a stand-alone utility.  It manipulates the way Cygwin sees the 
>> file system.  It has nothing to do with bash.  Since your program relies
>> on Cygwin and Cygwin interprets the file system through the existence or
>> absence of mount points, your program treats files as Cywgin would treat
>> the files, with or without bash.
>That's a point I don't understand. What sense can mount have without
>bash's unix-like environement ? Ok, it's not bash alone. It's everything
>around also. But I see a big difference between running from bash with
>everything around, which looks like unix, and running the compiled
>application from Windows' Dos Box. The only common thing I see is
>cygwin1.dll.

 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
You obviously don't look closely at what you type!;-)  This is the answer 
to all your questions/problems right here!  What do you think cygwin1.dll
is, padding to fill out your program so it looks like it takes up enough
space?  cygwin1.dll is the UNIX-emulation layer.  Everything else is just
an app.



>Regarding what you said before, I guess I'm wrong. Anyway, say I'll run
>mount from my friend's Dos Command Box, who has no cygnus system
>installes, what command am I supposed to type ? I don't see *where* I am
>supposed to mount the drives. Do you mean thet mount also can set the
>drives "mode" (text vs binary) without really mounting them ? 


Said it before but I'll say it again.  In the absence of mount points, 
Cywgin adopts defaults which it will use if it needs to.  That's text mode
in this case.


>> On Linux/UNIX, there's no difference between "binary" and "text" files, so
>> the added flag is inconsequential.  However, it is standard so whether the
>> docs mention it or not, its legal and will get you precisely what you want,
>> in a portable way.
>That may explain why I could not see the flag on linux's man pages. But
>there is no man page for open(2) on Cygwin, right ? Then, where am I
>supposed to find the value for this flag, if it ever exist ? I can't just
>invent it, I guess it won't work ;)


"b" is fine, as you indicated before.  Check the MSDN library at 
msdn.microsoft.com for one source.  I'm sure you can find this information
in any POSIX complaint UNIX API reference.


>> Happy to be of service.
>Maybe I could save your time. I feel a bit guilty... Is there a kind of
>reference manual for Cygwin that explain all this ? It doesn't sound that
>evident to me.


Try the user's guide.

http://www.cygwin.com/cygwin-ug-net/cygwin-ug-net.html




Larry Hall                              lhall@rfk.com
RFK Partners, Inc.                      http://www.rfk.com
118 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX
                                        


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 14:30           ` Jean Delvare
  2001-02-14 14:40             ` Christopher Faylor
@ 2001-02-14 14:51             ` Larry Hall (RFK Partners Inc)
  1 sibling, 0 replies; 36+ messages in thread
From: Larry Hall (RFK Partners Inc) @ 2001-02-14 14:51 UTC (permalink / raw)
  To: Jean Delvare, cygwin

At 05:27 PM 2/14/01, Jean Delvare wrote:

>> I doubt that Larry is pretending.  Mount does, of course, control the
>> behavior of any cygwin-compiled program.
>Thats a thing I just can't understand.
>I compile the program. Once compiled, it is supposed to work out of the
>Cygwin system. Anyone can take it together with the dll and run it on a

                                   ^^^^^^^^^^^^^^^^^^^^^^
This is the key phrase.  cygwin1.dll is always required.  If you use it,
it handles your program's interaction with the Windows' system.  Regardless
of whether there is an explicit mount point or not, Cygwin controls the
behavior.  For files, the default treatment is always text, unless a mount
or the program itself indicates otherwise.


>plate-form where cygwin has never been installed, right ?
>Then, there's no mount or anything like that. It's just the way Windows
>(and/or the dll) handles the thing !


No, Cygwin is still there.


>Definitely, there must be something in the whole process I don't
>understand correctly. Does mount change something in Windows' registry
>that any cygwin program can read and then change it's own behavior ?


Yes, mount manipulates the registry.  But if it has never been run, Cygwin
still adopts the default behavior of opening files as text unless the code
says otherwise.

You should check out the user's guide at www.cygwin.com.  It may help 
orient you a bit in this regard.


Larry Hall                              lhall@rfk.com
RFK Partners, Inc.                      http://www.rfk.com
118 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX
                                        


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 14:21         ` Larry Hall (RFK Partners Inc)
@ 2001-02-14 14:46           ` Jean Delvare
  2001-02-14 15:00             ` Larry Hall (RFK Partners Inc)
  2001-02-14 15:04             ` Christopher Faylor
  0 siblings, 2 replies; 36+ messages in thread
From: Jean Delvare @ 2001-02-14 14:46 UTC (permalink / raw)
  To: Larry Hall (RFK Partners Inc); +Cc: cygwin

> You proceed from a false supposition.
Looks like. Be sure I'm doing my best to understand, anyway.

> mount is a stand-alone utility.  It manipulates the way Cygwin sees the 
> file system.  It has nothing to do with bash.  Since your program relies
> on Cygwin and Cygwin interprets the file system through the existence or
> absence of mount points, your program treats files as Cywgin would treat
> the files, with or without bash.
That's a point I don't understand. What sense can mount have without
bash's unix-like environement ? Ok, it's not bash alone. It's everything
around also. But I see a big difference between running from bash with
everything around, which looks like unix, and running the compiled
application from Windows' Dos Box. The only common thing I see is
cygwin1.dll.

Regarding what you said before, I guess I'm wrong. Anyway, say I'll run
mount from my friend's Dos Command Box, who has no cygnus system
installes, what command am I supposed to type ? I don't see *where* I am
supposed to mount the drives. Do you mean thet mount also can set the
drives "mode" (text vs binary) without really mounting them ? 

> On Linux/UNIX, there's no difference between "binary" and "text" files, so
> the added flag is inconsequential.  However, it is standard so whether the
> docs mention it or not, its legal and will get you precisely what you want,
> in a portable way.
That may explain why I could not see the flag on linux's man pages. But
there is no man page for open(2) on Cygwin, right ? Then, where am I
supposed to find the value for this flag, if it ever exist ? I can't just
invent it, I guess it won't work ;)


> Happy to be of service.
Maybe I could save your time. I feel a bit guilty... Is there a kind of
reference manual for Cygwin that explain all this ? It doesn't sound that
evident to me.


-- 
       /~~       Jean "Khali" Delvare
  -----\_                        mail: delvare@ensicaen.ismra.fr
 --------\                http://www.ensicaen.ismra.fr/~delvare/
---=ISMRA/- ____________________________________________________


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 14:30           ` Jean Delvare
@ 2001-02-14 14:40             ` Christopher Faylor
  2001-02-14 14:51             ` Larry Hall (RFK Partners Inc)
  1 sibling, 0 replies; 36+ messages in thread
From: Christopher Faylor @ 2001-02-14 14:40 UTC (permalink / raw)
  To: cygwin

On Wed, Feb 14, 2001 at 11:27:42PM +0100, Jean Delvare wrote:
>Does mount change something in Windows' registry that any cygwin
>program can read and then change it's own behavior ?

Yes.

cgf

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 14:21         ` Christopher Faylor
@ 2001-02-14 14:30           ` Jean Delvare
  2001-02-14 14:40             ` Christopher Faylor
  2001-02-14 14:51             ` Larry Hall (RFK Partners Inc)
  0 siblings, 2 replies; 36+ messages in thread
From: Jean Delvare @ 2001-02-14 14:30 UTC (permalink / raw)
  To: cygwin

> I doubt that Larry is pretending.  Mount does, of course, control the
> behavior of any cygwin-compiled program.
Thats a thing I just can't understand.
I compile the program. Once compiled, it is supposed to work out of the
Cygwin system. Anyone can take it together with the dll and run it on a
plate-form where cygwin has never been installed, right ?
Then, there's no mount or anything like that. It's just the way Windows
(and/or the dll) handles the thing !

Definitely, there must be something in the whole process I don't
understand correctly. Does mount change something in Windows' registry
that any cygwin program can read and then change it's own behavior ?


-- 
       /~~       Jean "Khali" Delvare
  -----\_                        mail: delvare@ensicaen.ismra.fr
 --------\                http://www.ensicaen.ismra.fr/~delvare/
---=ISMRA/- ____________________________________________________


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 14:12       ` Jean Delvare
@ 2001-02-14 14:21         ` Christopher Faylor
  2001-02-14 14:30           ` Jean Delvare
  2001-02-14 14:21         ` Larry Hall (RFK Partners Inc)
  1 sibling, 1 reply; 36+ messages in thread
From: Christopher Faylor @ 2001-02-14 14:21 UTC (permalink / raw)
  To: cygwin; +Cc: delvare

On Wed, Feb 14, 2001 at 11:08:52PM +0100, Jean Delvare wrote:
>>Type "mount" on your system.  What does it show?  Is the file in
>>question being written under any of these mount points?  Any of them
>>binary?
>
>I think I understand the mount mechanism, and the binary vs text mode
>mount.  But I don't see the point when runing out of bash.  Do you
>pretend that the way I mount my drives with bash/mount changes the
>program behaviour when I run it directly from Windows ?  (I can hardly
>believe it)

I doubt that Larry is pretending.  Mount does, of course, control the
behavior of any cygwin-compiled program.

>>Bingo.  Cygwin treats files as text by default, unless you specify a
>>different default.  If you want your program to treat the file as
>>binary, add the appropriate flags on the appropriate calls.  Whamo!
>>Your problem is solved.
>
>I hope so.  That's also the way I see the thing.  The question is :
>What flags ?
>
>When using handles, I can solve the problem with fopen(f,"rb") instead
>of fopen(f,"r").  And it works.  But I read the whole read(2) man page
>(on Linux, it doesn't exist on Cygwin) and nowhere I saw a flag that
>force binary mode.  Can you help ?

Read the mount documentation.  It's on the cygwin web page.

cgf

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 14:12       ` Jean Delvare
  2001-02-14 14:21         ` Christopher Faylor
@ 2001-02-14 14:21         ` Larry Hall (RFK Partners Inc)
  2001-02-14 14:46           ` Jean Delvare
  1 sibling, 1 reply; 36+ messages in thread
From: Larry Hall (RFK Partners Inc) @ 2001-02-14 14:21 UTC (permalink / raw)
  To: Jean Delvare; +Cc: cygwin

At 05:08 PM 2/14/01, Jean Delvare wrote:


>> Type "mount" on your system.  What does it show?  Is the file in question
>> being written under any of these mount points?  Any of them binary?
>I think I understand the mount mechanism, and the binary vs text mode
>mount. But I don't see the point when runing out of bash. Do you pretend
>that the way I mount my drives with bash/mount changes the program
>behaviour when I run it directly from Windows ? (I can hardly believe it)

You proceed from a false supposition.

mount is a stand-alone utility.  It manipulates the way Cygwin sees the 
file system.  It has nothing to do with bash.  Since your program relies
on Cygwin and Cygwin interprets the file system through the existence or
absence of mount points, your program treats files as Cywgin would treat
the files, with or without bash.


>> Bingo.  Cygwin treats files as text by default, unless you specify a 
>> different default.  If you want your program to treat the file as binary,
>> add the appropriate flags on the appropriate calls.  Whamo!  Your problem
>> is solved.
>I hope so. That's also the way I see the thing. The question is : What
>flags ?
>When using handles, I can solve the problem with fopen(f,"rb") instead of
>fopen(f,"r"). And it works. But I read the whole read(2) man page (on
>Linux, it doesn't exist on Cygwin) and nowhere I saw a flag that force
>binary mode. Can you help ?


On Linux/UNIX, there's no difference between "binary" and "text" files, so
the added flag is inconsequential.  However, it is standard so whether the
docs mention it or not, its legal and will get you precisely what you want,
in a portable way.


>Anyway, thanks *a lot* for the help so far.


Happy to be of service.



Larry Hall                              lhall@rfk.com
RFK Partners, Inc.                      http://www.rfk.com
118 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX
                                        


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 13:58     ` Larry Hall (RFK Partners Inc)
@ 2001-02-14 14:12       ` Jean Delvare
  2001-02-14 14:21         ` Christopher Faylor
  2001-02-14 14:21         ` Larry Hall (RFK Partners Inc)
  0 siblings, 2 replies; 36+ messages in thread
From: Jean Delvare @ 2001-02-14 14:12 UTC (permalink / raw)
  To: Larry Hall (RFK Partners Inc); +Cc: cygwin

> Type "mount" on your system.  What does it show?  Is the file in question
> being written under any of these mount points?  Any of them binary?
I think I understand the mount mechanism, and the binary vs text mode
mount. But I don't see the point when runing out of bash. Do you pretend
that the way I mount my drives with bash/mount changes the program
behaviour when I run it directly from Windows ? (I can hardly believe it)

> Bingo.  Cygwin treats files as text by default, unless you specify a 
> different default.  If you want your program to treat the file as binary,
> add the appropriate flags on the appropriate calls.  Whamo!  Your problem
> is solved.
I hope so. That's also the way I see the thing. The question is : What
flags ?
When using handles, I can solve the problem with fopen(f,"rb") instead of
fopen(f,"r"). And it works. But I read the whole read(2) man page (on
Linux, it doesn't exist on Cygwin) and nowhere I saw a flag that force
binary mode. Can you help ?

Anyway, thanks *a lot* for the help so far.

-- 
       /~~       Jean "Khali" Delvare
  -----\_                        mail: delvare@ensicaen.ismra.fr
 --------\                http://www.ensicaen.ismra.fr/~delvare/
---=ISMRA/- ____________________________________________________


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 13:40   ` Jean Delvare
@ 2001-02-14 13:58     ` Larry Hall (RFK Partners Inc)
  2001-02-14 14:12       ` Jean Delvare
  0 siblings, 1 reply; 36+ messages in thread
From: Larry Hall (RFK Partners Inc) @ 2001-02-14 13:58 UTC (permalink / raw)
  To: Jean Delvare; +Cc: cygwin

At 04:37 PM 2/14/01, Jean Delvare wrote:

>> The output of cygcheck -s -r -v would undoubtedly point to the difference.
>> My guess is that you are either opening the file in a mounted file system
>> or the default mode for opening unmounted files is different on the two 
>> systems.  This has nothing to do with Windows.
>
>It must. Let me tell you more.


Fine but it still has nothing to do with Windows.


>I'm writing my program using cygwin on my Windows 98. It works from
>Cygwin's bash on my partition, all binary mounted. It works from Windows
>itself, run from Dos Command Prompt using cygwin1.dll version 1.1.8.

Type "mount" on your system.  What does it show?  Is the file in question
being written under any of these mount points?  Any of them binary?


>I send the executable and the dll to a friend running Windows 98 SE. The
>program fails. Analysing what's wrong. I could see the files were
>considered as text files.


Bingo.  Cygwin treats files as text by default, unless you specify a 
different default.  If you want your program to treat the file as binary,
add the appropriate flags on the appropriate calls.  Whamo!  Your problem
is solved.


>So, the comparison is between binary+dll on Windows 98 and binary+dll on
>Windows 98 SE. Is there somewhere (registry?) where cygwin looks to know
>if a given extension is text or binary ? I just can't figure out why I
>obtain a different behavior depending on Windows' version.


Because you don't.


>By the way, why doesn't Cygwin consider files as binary by default ? It
>would help a lot, isn't it ?


That's an old argument.  If you're interested in it, check the mail 
archives.  Its been argued back and forth there plenty!



Larry Hall                              lhall@rfk.com
RFK Partners, Inc.                      http://www.rfk.com
118 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX
                                        


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 13:22 ` Larry Hall (RFK Partners Inc)
@ 2001-02-14 13:40   ` Jean Delvare
  2001-02-14 13:58     ` Larry Hall (RFK Partners Inc)
  0 siblings, 1 reply; 36+ messages in thread
From: Jean Delvare @ 2001-02-14 13:40 UTC (permalink / raw)
  To: Larry Hall (RFK Partners Inc); +Cc: cygwin

> The output of cygcheck -s -r -v would undoubtedly point to the difference.
> My guess is that you are either opening the file in a mounted file system
> or the default mode for opening unmounted files is different on the two 
> systems.  This has nothing to do with Windows.

It must. Let me tell you more.
I'm writing my program using cygwin on my Windows 98. It works from
Cygwin's bash on my partition, all binary mounted. It works from Windows
itself, run from Dos Command Prompt using cygwin1.dll version 1.1.8.

I send the executable and the dll to a friend running Windows 98 SE. The
program fails. Analysing what's wrong. I could see the files were
considered as text files.

So, the comparison is between binary+dll on Windows 98 and binary+dll on
Windows 98 SE. Is there somewhere (registry?) where cygwin looks to know
if a given extension is text or binary ? I just can't figure out why I
obtain a different behavior depending on Windows' version.

By the way, why doesn't Cygwin consider files as binary by default ? It
would help a lot, isn't it ?


-- 
       /~~       Jean "Khali" Delvare
  -----\_                        mail: delvare@ensicaen.ismra.fr
 --------\                http://www.ensicaen.ismra.fr/~delvare/
---=ISMRA/- ____________________________________________________


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* Re: file descriptors opened as text files
  2001-02-14 13:13 Jean Delvare
@ 2001-02-14 13:22 ` Larry Hall (RFK Partners Inc)
  2001-02-14 13:40   ` Jean Delvare
  0 siblings, 1 reply; 36+ messages in thread
From: Larry Hall (RFK Partners Inc) @ 2001-02-14 13:22 UTC (permalink / raw)
  To: Jean Delvare, cygwin

At 04:10 PM 2/14/01, Jean Delvare wrote:

>Hello.
>
>I am opening a file with open(), and just read() from it. With Win 98, it
>is opened as a binary file. With Win 98 SE, it is opened as text file. How
>is it possible ?
>
>I'm not opening files on a mounted file system, but directly from Windows.
>Isn't supposed to be the same on all Windows versions ?


The output of cygcheck -s -r -v would undoubtedly point to the difference.
My guess is that you are either opening the file in a mounted file system
or the default mode for opening unmounted files is different on the two 
systems.  This has nothing to do with Windows.


Larry Hall                              lhall@rfk.com
RFK Partners, Inc.                      http://www.rfk.com
118 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX
                                        


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

* file descriptors opened as text files
@ 2001-02-14 13:13 Jean Delvare
  2001-02-14 13:22 ` Larry Hall (RFK Partners Inc)
  0 siblings, 1 reply; 36+ messages in thread
From: Jean Delvare @ 2001-02-14 13:13 UTC (permalink / raw)
  To: cygwin

Hello.

I am opening a file with open(), and just read() from it. With Win 98, it
is opened as a binary file. With Win 98 SE, it is opened as text file. How
is it possible ?

I'm not opening files on a mounted file system, but directly from Windows.
Isn't supposed to be the same on all Windows versions ?

-- 
       /~~       Jean "Khali" Delvare
  -----\_                        mail: delvare@ensicaen.ismra.fr
 --------\                http://www.ensicaen.ismra.fr/~delvare/
---=ISMRA/- ____________________________________________________


--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 36+ messages in thread

end of thread, other threads:[~2001-02-16  8:12 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-02-15 15:53 file descriptors opened as text files Heribert Dahms
2001-02-15 16:06 ` Larry Hall (RFK Partners, Inc)
2001-02-15 18:26   ` Christopher Faylor
2001-02-16  8:12 ` Ehud Karni
  -- strict thread matches above, loose matches on Subject: below --
2001-02-14 13:13 Jean Delvare
2001-02-14 13:22 ` Larry Hall (RFK Partners Inc)
2001-02-14 13:40   ` Jean Delvare
2001-02-14 13:58     ` Larry Hall (RFK Partners Inc)
2001-02-14 14:12       ` Jean Delvare
2001-02-14 14:21         ` Christopher Faylor
2001-02-14 14:30           ` Jean Delvare
2001-02-14 14:40             ` Christopher Faylor
2001-02-14 14:51             ` Larry Hall (RFK Partners Inc)
2001-02-14 14:21         ` Larry Hall (RFK Partners Inc)
2001-02-14 14:46           ` Jean Delvare
2001-02-14 15:00             ` Larry Hall (RFK Partners Inc)
2001-02-14 16:54               ` Ross Smith
2001-02-14 19:28                 ` Christopher Faylor
2001-02-15  1:36                 ` Jesper Eskilson
2001-02-15  6:39               ` Jean Delvare
2001-02-15  7:54                 ` Larry Hall (RFK Partners, Inc)
2001-02-15  9:21                   ` Jean Delvare
2001-02-15  9:24                     ` Larry Hall (RFK Partners, Inc)
2001-02-15 10:37                     ` Christopher Faylor
2001-02-15  7:59                 ` DJ Delorie
2001-02-15  9:12                   ` Jean Delvare
2001-02-15  9:17                     ` Larry Hall (RFK Partners, Inc)
2001-02-15  9:28                       ` Jean Delvare
2001-02-15  9:37                         ` Larry Hall (RFK Partners, Inc)
2001-02-15 10:38                         ` Christopher Faylor
2001-02-15 10:11                     ` Earnie Boyd
2001-02-15  8:04                 ` Corinna Vinschen
2001-02-15  8:04                 ` Earnie Boyd
2001-02-15  9:30                   ` Jean Delvare
2001-02-15 21:11                 ` Lothan
2001-02-14 15:04             ` Christopher Faylor
     [not found] <BF35D9C143BCCC4EB63181B67C9320C804DD0F@serv-075.icon-germa>

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).