From e7c8fb89d38801affa743b0c1d8ef990b3c2f431 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Mon, 3 Jun 2019 09:17:02 +1000 Subject: proj_info().searchpath should not include PROJ_LIB path if the context search_paths is not empty The logic used when actually searching for files is that if the context search_paths are set, these completely override the PROJ_LIB variable. So we should make proj_info().searchpath correctly reflect this, and not include the PROJ_LIB path in searchpath if the context has search_paths manually set. --- src/4D_api.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/4D_api.cpp') diff --git a/src/4D_api.cpp b/src/4D_api.cpp index 81e16600..5d84e6c6 100644 --- a/src/4D_api.cpp +++ b/src/4D_api.cpp @@ -1403,16 +1403,17 @@ PJ_INFO proj_info (void) { info.release = pj_get_release (); /* build search path string */ - const char* envPROJ_LIB = getenv ("PROJ_LIB"); - buf = path_append (buf, envPROJ_LIB, &buf_size); + auto ctx = pj_get_default_ctx(); + if (!ctx || ctx->search_paths.empty()) { + const char *envPROJ_LIB = getenv("PROJ_LIB"); + buf = path_append(buf, envPROJ_LIB, &buf_size); #ifdef PROJ_LIB - if( envPROJ_LIB == nullptr ) { - buf = path_append (buf, PROJ_LIB, &buf_size); - } + if (envPROJ_LIB == nullptr) { + buf = path_append(buf, PROJ_LIB, &buf_size); + } #endif - auto ctx = pj_get_default_ctx(); - if( ctx ) { - for( const auto& path: ctx->search_paths ) { + } else { + for (const auto &path : ctx->search_paths) { buf = path_append(buf, path.c_str(), &buf_size); } } -- cgit v1.2.3