public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* 0x1a bug - its not just awk
@ 1999-11-22 12:38 Gareth Williams
  1999-11-22 14:51 ` Chris Faylor
  1999-11-30 23:39 ` Gareth Williams
  0 siblings, 2 replies; 6+ messages in thread
From: Gareth Williams @ 1999-11-22 12:38 UTC (permalink / raw)
  To: cygwin; +Cc: gareth

I just downloaded B20.1 and compiled a few C++ programs under NT4.
Those that write data work fine. Those that read fail on the byte
0x1a.

I have seen the reports that awk can not read the byte 0x1a.

Well, the problem is not with awk. "cat" can't read it. 
"cin.get(c)" can't read it. However cp can copy it. And it is
OK reading from a pipe, just not from a file.

Attached:

bytesout.cpp:   writes out 10 bytes with 0x1a the 7th byte.
bytesin.cpp:    reads bytes, prints them and gives a count

(compiled with g++: g++ -o x x.cpp)

This happens:

$ bytesout > tmp             ## produces a 10 byte file
$ bytesin < tmp              ## produces a count of 6 bytes
$ cat tmp > tmp2             ## produces a 6 byte file

but
$ bytesout | bytesin         ## reports 10 bytes
$ bytesout | cat | bytesin   ## reports 10 bytes
$ cp tmp tmp2                ## produces a 10 byte file

If you put the 0x1a in different places it does what you
expect (fails on that byte) except if 0x1a is the second
byte it reads zero bytes.

So I would guess the problem is in some low-level I/O
routine that is used by fstream, and by cat, but not by cp.

PS I am a first time user of CYGWIN and was very impressed
by the ease with which I could port my C++ project
(developed with egcs on SGI and Linux) to NT, even though rather
bemused by this strange bug.

cheers

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

* Re: 0x1a bug - its not just awk
  1999-11-22 12:38 0x1a bug - its not just awk Gareth Williams
@ 1999-11-22 14:51 ` Chris Faylor
  1999-11-30 23:39   ` Chris Faylor
  1999-11-30 23:39 ` Gareth Williams
  1 sibling, 1 reply; 6+ messages in thread
From: Chris Faylor @ 1999-11-22 14:51 UTC (permalink / raw)
  To: Gareth Williams; +Cc: cygwin, gareth

On Mon, Nov 22, 1999 at 08:35:17PM +0000, Gareth Williams wrote:
>I just downloaded B20.1 and compiled a few C++ programs under NT4.
>Those that write data work fine. Those that read fail on the byte
>0x1a.
>
>I have seen the reports that awk can not read the byte 0x1a.

If you've seen the reports, you should be aware that this is not a bug
but a feature.  This character is considered to be an EOF character by
both cygwin and MSVC.

The solution is to use binary mounts, i.e., mount the directory using
the -b option:

mount -b c:\somedir /somedir

That will cause files in that directory to be interpreted as normal UNIX
streams of bytes.

cgf

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

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

* Re: 0x1a bug - its not just awk
  1999-11-22 14:51 ` Chris Faylor
@ 1999-11-30 23:39   ` Chris Faylor
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Faylor @ 1999-11-30 23:39 UTC (permalink / raw)
  To: Gareth Williams; +Cc: cygwin, gareth

On Mon, Nov 22, 1999 at 08:35:17PM +0000, Gareth Williams wrote:
>I just downloaded B20.1 and compiled a few C++ programs under NT4.
>Those that write data work fine. Those that read fail on the byte
>0x1a.
>
>I have seen the reports that awk can not read the byte 0x1a.

If you've seen the reports, you should be aware that this is not a bug
but a feature.  This character is considered to be an EOF character by
both cygwin and MSVC.

The solution is to use binary mounts, i.e., mount the directory using
the -b option:

mount -b c:\somedir /somedir

That will cause files in that directory to be interpreted as normal UNIX
streams of bytes.

cgf

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

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

* 0x1a bug - its not just awk
  1999-11-22 12:38 0x1a bug - its not just awk Gareth Williams
  1999-11-22 14:51 ` Chris Faylor
@ 1999-11-30 23:39 ` Gareth Williams
  1 sibling, 0 replies; 6+ messages in thread
From: Gareth Williams @ 1999-11-30 23:39 UTC (permalink / raw)
  To: cygwin; +Cc: gareth

I just downloaded B20.1 and compiled a few C++ programs under NT4.
Those that write data work fine. Those that read fail on the byte
0x1a.

I have seen the reports that awk can not read the byte 0x1a.

Well, the problem is not with awk. "cat" can't read it. 
"cin.get(c)" can't read it. However cp can copy it. And it is
OK reading from a pipe, just not from a file.

Attached:

bytesout.cpp:   writes out 10 bytes with 0x1a the 7th byte.
bytesin.cpp:    reads bytes, prints them and gives a count

(compiled with g++: g++ -o x x.cpp)

This happens:

$ bytesout > tmp             ## produces a 10 byte file
$ bytesin < tmp              ## produces a count of 6 bytes
$ cat tmp > tmp2             ## produces a 6 byte file

but
$ bytesout | bytesin         ## reports 10 bytes
$ bytesout | cat | bytesin   ## reports 10 bytes
$ cp tmp tmp2                ## produces a 10 byte file

If you put the 0x1a in different places it does what you
expect (fails on that byte) except if 0x1a is the second
byte it reads zero bytes.

So I would guess the problem is in some low-level I/O
routine that is used by fstream, and by cat, but not by cp.

PS I am a first time user of CYGWIN and was very impressed
by the ease with which I could port my C++ project
(developed with egcs on SGI and Linux) to NT, even though rather
bemused by this strange bug.

cheers

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

* Re: 0x1a bug - its not just awk
  1999-11-22 13:12 Earnie Boyd
@ 1999-11-30 23:39 ` Earnie Boyd
  0 siblings, 0 replies; 6+ messages in thread
From: Earnie Boyd @ 1999-11-30 23:39 UTC (permalink / raw)
  To: Gareth Williams, cygwin; +Cc: gareth

--- Gareth Williams <dgwilliams@dera.gov.uk> wrote:
> I just downloaded B20.1 and compiled a few C++ programs under NT4.
> Those that write data work fine. Those that read fail on the byte
> 0x1a.
> 
> I have seen the reports that awk can not read the byte 0x1a.
> 
> Well, the problem is not with awk. "cat" can't read it. 
> "cin.get(c)" can't read it. However cp can copy it. And it is
> OK reading from a pipe, just not from a file.
> 
-8<-

cat and awk are _text_ utilities. (no flames please)  This has to do with text
mode file processing vs binary mode file processing.  Please visit my webpage
and search the archives for explainations.



=====
Earnie Boyd < mailto:earnie_boyd@yahoo.com >
Cygwin Newbies, please visit
< http://www.freeyellow.com/members5/gw32/index.html >
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

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

* Re: 0x1a bug - its not just awk
@ 1999-11-22 13:12 Earnie Boyd
  1999-11-30 23:39 ` Earnie Boyd
  0 siblings, 1 reply; 6+ messages in thread
From: Earnie Boyd @ 1999-11-22 13:12 UTC (permalink / raw)
  To: Gareth Williams, cygwin; +Cc: gareth

--- Gareth Williams <dgwilliams@dera.gov.uk> wrote:
> I just downloaded B20.1 and compiled a few C++ programs under NT4.
> Those that write data work fine. Those that read fail on the byte
> 0x1a.
> 
> I have seen the reports that awk can not read the byte 0x1a.
> 
> Well, the problem is not with awk. "cat" can't read it. 
> "cin.get(c)" can't read it. However cp can copy it. And it is
> OK reading from a pipe, just not from a file.
> 
-8<-

cat and awk are _text_ utilities. (no flames please)  This has to do with text
mode file processing vs binary mode file processing.  Please visit my webpage
and search the archives for explainations.



=====
Earnie Boyd < mailto:earnie_boyd@yahoo.com >
Cygwin Newbies, please visit
< http://www.freeyellow.com/members5/gw32/index.html >
__________________________________________________
Do You Yahoo!?
Bid and sell for free at http://auctions.yahoo.com

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com

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

end of thread, other threads:[~1999-11-30 23:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-11-22 12:38 0x1a bug - its not just awk Gareth Williams
1999-11-22 14:51 ` Chris Faylor
1999-11-30 23:39   ` Chris Faylor
1999-11-30 23:39 ` Gareth Williams
1999-11-22 13:12 Earnie Boyd
1999-11-30 23:39 ` Earnie Boyd

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