Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Tue, 29 Jul 2003 08:19:33 -0400 (EDT)
From: Igor Pechtchanski <pechtcha@cs.nyu.edu>
Reply-To: cygwin@cygwin.com
To: =?iso-8859-1?Q?J=F8rgen?= =?iso-8859-1?Q?_?= =?iso-8859-1?Q?N=F8rgaard?= <jnp@smarttv.dk>
cc: cygwin@cygwin.com, <cygwin-apps@cygwin.com>
Subject: Re: gcj file input problem, "available" incorrect
In-Reply-To: <p06001a08bb4bf9328842@[192.168.1.249]>
Message-ID: <Pine.GSO.4.44.0307290818440.14714-100000@slinky.cs.nyu.edu>
Importance: Normal
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=ISO-8859-1
Content-Transfer-Encoding: 8BIT

Wrong list, redirecting.  Please use the <cygwin at cygwin dot com> list
for all further discussion.
	Igor

On Tue, 29 Jul 2003, Jørgen Nørgaard wrote:

> Hi,
>
> while using the gcj component of gcc (java compiler frontemd for gcc)
> we have found a peculiar problem with FileInputStreams on Windows
> (XP).
>
>
> Given Freader.java:
> import java.io.*;
>
> public class Freader {
>         static public void main(String arg[]) {
>                 try {
>                 File f=new File("inp.txt");
>                 FileInputStream fis=new FileInputStream(f);
>                 int inp;
>                 int count=0;
>                 while ((inp=fis.read())!=-1) {
>                         count++;
>                 }
>                 fis.close();
>                 System.out.println("#1 " + count);
>
>                 fis=new FileInputStream(f);
>                              count=0;
>                 fis.available();
>                 while ((inp=fis.read())!=-1) {
>                         count++;
>                 }
>                 fis.close();
>                 System.out.println("#2 " + count);
>                 } catch (Exception e) {
>                         e.printStackTrace();
>                 }
>         }
> }
>
>
> File inp.txt:
> weapons of mass destruction
>
>
> that should report the same number of bytes read from the file
> "inp.txt" in both cases. And does so using javac/java on both Linux
> and Windows.
>
>
> With gcj (v 3.2) on Linux the program works fine.
>
> On Windows, however, the call to 'available' seem to consume input,
> see output below.
>
>
> Is this a known issue with gcc/gcj on Windows?
>
>
> Output on windows:
> a.exe
> #1 31
> #2 30
>
> $ gcj --version
> gcj (GCC) 3.2 20020927 (prerelease)
> Copyright (C) 2002 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
>
> The installation is from cygwin/redhat appears to be up-to-date.
> Regards,

-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

