OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.91k stars 2.55k forks source link

CPL_DEBUG does not accept "YES" or "TRUE" #11219

Closed dbaston closed 1 week ago

dbaston commented 1 week ago
          > Any config option should accept any of these values. But the documentation probably does not give that impression.

Should or already does? At the moment, CPL_DEBUG=ON works, but YES and TRUE don't.

Originally posted by @lnicola in https://github.com/OSGeo/gdal/issues/8440#issuecomment-2461386030

Nearby, CPL_TIMESTAMP interprets any value as "YES", including "NO".

rouault commented 1 week ago

Yes we should support YES,TRUE,ON,1 . For CPL_DEBUG, we can't use CPLTestBool() for that, since CPL_DEBUG also accepts other strings to filter by component. For CPL_TIMESTAMP, we should just use CPLTestBool()

rouault commented 1 week ago

And we should likely enhance CPLTestBool() to warn if the string passed to it is not one of YES,TRUE,ON,1,NO,FALSE,OFF,0

dbaston commented 1 week ago

And we should likely enhance CPLTestBool() to warn if the string passed to it is not one of YES,TRUE,ON,1,NO,FALSE,OFF,0

It wouldn't hurt for now, but unless I'm mistaken there would be no way for the error message to contain the context from which it was called?

Longer-term, something returning a std::optional<bool> would let the caller issue a more informative message. (https://github.com/OSGeo/gdal/issues/9953)