Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT 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 Reply-To: cygwin AT cygwin DOT com To: =?iso-8859-1?Q?J=F8rgen?= =?iso-8859-1?Q?_?= =?iso-8859-1?Q?N=F8rgaard?= cc: cygwin AT cygwin DOT com, Subject: Re: gcj file input problem, "available" incorrect In-Reply-To: Message-ID: Importance: Normal MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Wrong list, redirecting. Please use the 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 AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT 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/