This is the mail archive of the cygwin-apps@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

gcj file input problem, "available" incorrect


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,
--
/jørgen nørgaard
SmartTV A/S
jnp@smarttv.dk
Phone: +45 3332 5770
http://smarttv.dk/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]