From bug-octave-request at bevo dot che dot wisc dot edu Fri Dec 19 15:47:31 2003 Subject: ftell - position of file pointer cannot be tested From: "John W. Eaton" To: Schloegl Alois Cc: bug-octave at bevo dot che dot wisc dot edu Date: Fri, 19 Dec 2003 15:47:26 -0600 On 19-Dec-2003, Schloegl Alois wrote: | Bug report for Octave 2.1.52 configured for i686-pc-linux-gnu | | Description: | ----------- | | | fid = fopen(anyfile); | s = fread(fid,500,'char'); | octave:4> ftell(fid)~=500 | error: binary operator `==' not implemented for `streamoff' by `scalar' | operations | error: evaluating binary operator `==' near line 4, column 11 | | ftell returns a value of type 'streamoff' which cannot be compared against a | numeric value. In this way, ftell is pretty useless. | | Is there any reason, why ftell does not return a scalar value? Yes, because the object that is returned by the C++ stream classes to represent file positions is no longer a long integer, and can't be converted to one (it might not fit). There was a short discussion about this problem a month or two ago, I think on the octave-maintainers mailing list. | Repeat-By: | --------- | | fid = fopen(anyfile); | s = fread(fid,500,'char'); | ftell(fid)==500, | error: binary operator `==' not implemented for `streamoff' by `scalar' | operations | error: evaluating binary operator `==' near line 4, column 11 | | Fix: | --- | | ftell should return a scalar value or | the comparison operator must handle "streamoff" data. I think the comparision operator does handle streamoff data. But you are comparing a streamoff object with a scalar (double precision number). AFAICT, the underlying C++ objects have no way to convert between the two, so I don't see a good way to fix this. jwe ------------------------------------------------------------- Octave is freely available under the terms of the GNU GPL. Octave's home on the web: http://www.octave.org How to fund new projects: http://www.octave.org/funding.html Subscription information: http://www.octave.org/archive.html -------------------------------------------------------------