public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* RE: gcc for WinNT
@ 1997-03-07  0:05 Sergey Okhapkin
  0 siblings, 0 replies; 10+ messages in thread
From: Sergey Okhapkin @ 1997-03-07  0:05 UTC (permalink / raw)
  To: 'Ron G. Minnich'; +Cc: gnu-win32

Ron G. Minnich wrote:
> One thing I have seen: file i/o does not always works as it does on unix. 
> For example, reading from a file, 1024 bytes at a time, with a file of 
> 65536 bytes, will get me return values of:
> 1023, 1021, 1015, etc. Almost always 1024, but enough of these oddballs 

You should open the file in binary mode.

-- 
Sergey Okhapkin
Moscow, Russia
Looking for a job.


-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

* Re: gcc for WinNT
       [not found] <199703072049.PAA27466.cygnus.gnu-win32@cinna.ultra.net>
@ 1997-03-13  9:41 ` Michael Meissner
  0 siblings, 0 replies; 10+ messages in thread
From: Michael Meissner @ 1997-03-13  9:41 UTC (permalink / raw)
  To: gnu-win32

jdennis@ultranet.com ("John R. Dennis") writes:

> There are many ways to set binary vs. text mode on a file stream.
> 
> in fopen add either the b (binary) or the t (text) character in
> the mode string, e.g. fopen(filename "rb") to open a file for binary
> reading. 

Umm, if you want your code to be portable, don't use the t in the mode string.
Ie, use "r" for read-only text files, and "rb" for read-only binary files.

-- 
Michael Meissner, Cygnus Solutions (East Coast)
4th floor, 955 Massachusetts Avenue, Cambridge, MA 02139, USA
meissner@cygnus.com,	617-354-5416 (office),	617-354-7161 (fax)
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

* Re: gcc for WinNT
  1997-03-07  8:08     ` Ron G. Minnich
  1997-03-07 16:11       ` Jim Balter
@ 1997-03-07 17:24       ` John R. Dennis
  1997-03-07 17:24         ` Jim Balter
  1 sibling, 1 reply; 10+ messages in thread
From: John R. Dennis @ 1997-03-07 17:24 UTC (permalink / raw)
  To: rminnich; +Cc: jqb, kokyong, gnu-win32

>>>>> "Ron" == Ron G Minnich <rminnich@sarnoff.com> writes:

    Ron> reading in text mode? this is a simple int fd = open("file",
    Ron> O_RDONLY); fd = read(blah blah)

    Ron> How do you control text mode from that? new options or an
    Ron> fcntl?  ron - For help on using this list, send a message to
    Ron> "gnu-win32-request@cygnus.com" with one line of text: "help".

There are many ways to set binary vs. text mode on a file stream.

in fopen add either the b (binary) or the t (text) character in
the mode string, e.g. fopen(filename "rb") to open a file for binary
reading. 

In open() bitwise OR one of _O_BINARY, _O_TEXT flags.

You can call _setmode(handle, mode) where mode is
_O_TEXT or _O_BINARY after a file is open,  for example:

   /* Set "stdin" to have binary mode: */
   result = _setmode( _fileno( stdin ), _O_BINARY );
   if( result == -1 )
      perror( "Cannot set mode" );
   else
      printf( "'stdin' successfully changed to binary mode\n" );


You can set the global variable _fmode. The _fmode variable sets the
default file-translation mode for text or binary translation. It is
declared in STDLIB.H as extern int _fmode;
  
The default setting of _fmode is _O_TEXT, for text-mode
translation. _O_BINARY is the setting for binary mode.  You can change
the value of _fmode in either of two ways: Link with BINMODE.OBJ. This
changes the initial setting of _fmode to _O_BINARY, causing all files
except stdin, stdout, and stderr to be opened in binary mode.
Change the value of _fmode directly by setting it in your program.

Hope that helps,

John Dennis

-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

* Re: gcc for WinNT
  1997-03-07 17:24       ` John R. Dennis
@ 1997-03-07 17:24         ` Jim Balter
  1997-03-07 17:24           ` John R. Dennis
  0 siblings, 1 reply; 10+ messages in thread
From: Jim Balter @ 1997-03-07 17:24 UTC (permalink / raw)
  To: John R. Dennis; +Cc: rminnich, kokyong, gnu-win32

John R. Dennis wrote:
> 
> >>>>> "Ron" == Ron G Minnich <rminnich@sarnoff.com> writes:
> 
>     Ron> reading in text mode? this is a simple int fd = open("file",
>     Ron> O_RDONLY); fd = read(blah blah)
> 
>     Ron> How do you control text mode from that? new options or an
>     Ron> fcntl?  ron - For help on using this list, send a message to
>     Ron> "gnu-win32-request@cygnus.com" with one line of text: "help".
> 
> There are many ways to set binary vs. text mode on a file stream.
> 
> in fopen add either the b (binary) or the t (text) character in
> the mode string, e.g. fopen(filename "rb") to open a file for binary
> reading.
> 
> In open() bitwise OR one of _O_BINARY, _O_TEXT flags.
> 
> You can call _setmode(handle, mode) where mode is
> _O_TEXT or _O_BINARY after a file is open,  for example:
> 
>    /* Set "stdin" to have binary mode: */
>    result = _setmode( _fileno( stdin ), _O_BINARY );
>    if( result == -1 )
>       perror( "Cannot set mode" );
>    else
>       printf( "'stdin' successfully changed to binary mode\n" );
> 
> You can set the global variable _fmode. The _fmode variable sets the
> default file-translation mode for text or binary translation. It is
> declared in STDLIB.H as extern int _fmode;
> 
> The default setting of _fmode is _O_TEXT, for text-mode
> translation. _O_BINARY is the setting for binary mode.  You can change
> the value of _fmode in either of two ways: Link with BINMODE.OBJ. This
> changes the initial setting of _fmode to _O_BINARY, causing all files
> except stdin, stdout, and stderr to be opened in binary mode.
> Change the value of _fmode directly by setting it in your program.
> 
> Hope that helps,

These look like instructions for MSVC, not cygwin.
In cygwin, there's no _ in front of O_TEXT, O_BINARY, or fileno,
there's no BINMODE.OBJ, and _fmode is not defined in stdlib.h
or any other header file.

Also, setmode only fails if fd doesn't represent an open file,
so it's rather a waste to check its return value.
Also, beware that in MSVC setmode returns the previous mode, whereas in
cygwin it returns 0 (there seems to have been a persistent failure by
the original author of cygwin to ever read the documentation of the
systems he was emulating, be it MSVC or POSIX).  RCS, for one, assumes
the MSVC behavior.

--
<J Q B>
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

* Re: gcc for WinNT
  1997-03-07 17:24         ` Jim Balter
@ 1997-03-07 17:24           ` John R. Dennis
  0 siblings, 0 replies; 10+ messages in thread
From: John R. Dennis @ 1997-03-07 17:24 UTC (permalink / raw)
  To: jqb; +Cc: rminnich, kokyong, gnu-win32

>>>>> "Jim" == Jim Balter <jqb@netcom.com> writes:

    Jim> These look like instructions for MSVC, not cygwin.

Yes, you are absolutely correct. I misunderstood the original question
and appologize for adding any confusion.

John

-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

* Re: gcc for WinNT
  1997-03-07  8:08     ` Ron G. Minnich
@ 1997-03-07 16:11       ` Jim Balter
  1997-03-07 17:24       ` John R. Dennis
  1 sibling, 0 replies; 10+ messages in thread
From: Jim Balter @ 1997-03-07 16:11 UTC (permalink / raw)
  To: Ron G. Minnich; +Cc: Leong Kok Yong, gnu-win32

Ron G. Minnich wrote:
> 
> On Thu, 6 Mar 1997, Jim Balter wrote:
> > When reading in text mode, cygwin deletes CRs but neglects to read
> > more to fill out the buffer.
> 
> reading in text mode? this is a simple
> int fd = open("file", O_RDONLY);
> fd = read(blah blah)
> 
> How do you control text mode from that? new options or an fcntl?
> ron

open("file", O_RDONLY|O_BINARY)

or

...; setmode(fd, O_BINARY);

or mount -b ...


Time to read the FAQ, methinks.

--
<J Q B>
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

* Re: gcc for WinNT
  1997-03-06 10:25 ` Ron G. Minnich
@ 1997-03-07  8:08   ` Jim Balter
  1997-03-07  8:08     ` Ron G. Minnich
  0 siblings, 1 reply; 10+ messages in thread
From: Jim Balter @ 1997-03-07  8:08 UTC (permalink / raw)
  To: Ron G. Minnich; +Cc: Leong Kok Yong, gnu-win32

Ron G. Minnich wrote:
> 
> One thing I have seen: file i/o does not always works as it does on unix.
> For example, reading from a file, 1024 bytes at a time, with a file of
> 65536 bytes, will get me return values of:
> 1023, 1021, 1015, etc. Almost always 1024, but enough of these oddballs
> to cause trouble for programs that don't carefully check return values
> from read() (there are some of these ...). I had to fix the rtsp ref.
> port from realaudio to accomodate this strange read(2) behavior.

When reading in text mode, cygwin deletes CRs but neglects to read
more to fill out the buffer.

The chances are good that you don't want to be reading in text mode
in the first place.

--
<J Q B>
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

* Re: gcc for WinNT
  1997-03-07  8:08   ` Jim Balter
@ 1997-03-07  8:08     ` Ron G. Minnich
  1997-03-07 16:11       ` Jim Balter
  1997-03-07 17:24       ` John R. Dennis
  0 siblings, 2 replies; 10+ messages in thread
From: Ron G. Minnich @ 1997-03-07  8:08 UTC (permalink / raw)
  To: Jim Balter; +Cc: Leong Kok Yong, gnu-win32

On Thu, 6 Mar 1997, Jim Balter wrote:
> When reading in text mode, cygwin deletes CRs but neglects to read
> more to fill out the buffer.

reading in text mode? this is a simple 
int fd = open("file", O_RDONLY);
fd = read(blah blah)

How do you control text mode from that? new options or an fcntl? 
ron
-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

* Re: gcc for WinNT
  1997-03-06  0:03 Leong Kok Yong
@ 1997-03-06 10:25 ` Ron G. Minnich
  1997-03-07  8:08   ` Jim Balter
  0 siblings, 1 reply; 10+ messages in thread
From: Ron G. Minnich @ 1997-03-06 10:25 UTC (permalink / raw)
  To: Leong Kok Yong; +Cc: gnu-win32

One thing I have seen: file i/o does not always works as it does on unix. 
For example, reading from a file, 1024 bytes at a time, with a file of 
65536 bytes, will get me return values of:
1023, 1021, 1015, etc. Almost always 1024, but enough of these oddballs 
to cause trouble for programs that don't carefully check return values 
from read() (there are some of these ...). I had to fix the rtsp ref. 
port from realaudio to accomodate this strange read(2) behavior.

ron

Ron Minnich                |"Failure is not an option" -- Gene Kranz
rminnich@sarnoff.com       | -- except, of course, on Microsoft products
(609)-734-3120             |
ftp://ftp.sarnoff.com/pub/mnfs/www/docs/cluster.html 


-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

* gcc for WinNT
@ 1997-03-06  0:03 Leong Kok Yong
  1997-03-06 10:25 ` Ron G. Minnich
  0 siblings, 1 reply; 10+ messages in thread
From: Leong Kok Yong @ 1997-03-06  0:03 UTC (permalink / raw)
  To: gnu-win32

i install cygnus port of gcc for windows nt 4.0 (beta 17.1)

after some tickering here and there, it works!
except some funny things happened..

i was porting a unix software to the NT 4.0 running on Intel

using the same binary .exe i compiled, the GIF images generated does not
comes out correctly sometimes

sometimes it works fine, sometimes just a blank image, sometimes half the
image...
why is that so?

a correct implementation would be at
http://www.irdu.nus.sg/cgi-bin/ml/gbfilt?http://www.irdu.nus.sg/multilingual/mirage/sample/tangshi_content.gb.html
(CGI-BIN program running on a unix server)

the broken port to NT is at
http://astmis.irdu.nus.sg/cgi-bin/mirage/gbfilt.pl?http://www.irdu.nus.sg/multilingual/mirage/mirage/sample/tangshi_content.gb.html


please help
thanks
:)



-
For help on using this list, send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".

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

end of thread, other threads:[~1997-03-13  9:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-03-07  0:05 gcc for WinNT Sergey Okhapkin
     [not found] <199703072049.PAA27466.cygnus.gnu-win32@cinna.ultra.net>
1997-03-13  9:41 ` Michael Meissner
  -- strict thread matches above, loose matches on Subject: below --
1997-03-06  0:03 Leong Kok Yong
1997-03-06 10:25 ` Ron G. Minnich
1997-03-07  8:08   ` Jim Balter
1997-03-07  8:08     ` Ron G. Minnich
1997-03-07 16:11       ` Jim Balter
1997-03-07 17:24       ` John R. Dennis
1997-03-07 17:24         ` Jim Balter
1997-03-07 17:24           ` John R. Dennis

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).