[Gdal-dev] CPLReadLine() / CPLFGets()

Frank Warmerdam warmerdam at pobox.com
Fri Sep 12 16:57:54 EDT 2003


Folks,

In late august the CPLFGets() function was implement, and CPLReadLine()
was modified to use it.  The intent, as I recall, was to compartmentalize
the the "newline detection" portion of CPLReadLine() and to add support
for \r newlines as occur sometimes (always?) in MacOS files.

However, the change required that CPLReadLine() only be used with files
opened in binary mode, because of the use of fseek() to restore the file
pointer back when only part of a line should be read.  Many pieces of
code using CPLReadLine() do *not* open their files in binary mode, and
were badly broken on windows (ie. MIF reader, TAB reader, S-57 support)

While we could try to identify all these places and switch to binary mode,
it seems this is a fragile solution and there would likely be future bugs
that only occur on Windows if that approach is taken.   So, instead I have
reviewed CPLFGets() and reimplemented it in a way that I believe is still
stable on files opened in text mode on windows.

I want everyeone to know that any windows GDAL builds since August 25th, 2003
will be badly broken for some things, and encourage folks to upgrade to the
nightly snapshot that comes out tomorrow.

Also, let me know if I have broken things in subtle ways I am not realizing.

Andrey ... could you verify that my new CPLFGets() actually works for the
problem you were trying to solve?  I constructed a pretty pathological
text files to test on and it seemed to work well but I am not sure I
understood your original intent.

Best regards,

-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent





More information about the Gdal-dev mailing list