From 56f0ad70054eea15e9671cd67aafd14bf7c11c74 Mon Sep 17 00:00:00 2001 From: Kristian Evers Date: Wed, 18 Nov 2020 10:43:16 +0100 Subject: Remove pj_errno and related functions --- src/4D_api.cpp | 1 - src/Makefile.am | 2 +- src/apps/cct.cpp | 4 ++-- src/apps/cs2cs.cpp | 2 +- src/apps/gie.cpp | 8 ++++---- src/apps/proj.cpp | 8 +++----- src/errno.cpp | 18 ------------------ src/internal.cpp | 1 - src/lib_proj.cmake | 1 - src/pipeline.cpp | 2 +- src/proj_internal.h | 3 --- src/strerrno.cpp | 13 +++++-------- 12 files changed, 17 insertions(+), 46 deletions(-) delete mode 100644 src/errno.cpp (limited to 'src') diff --git a/src/4D_api.cpp b/src/4D_api.cpp index 78e9bdc3..83fda02c 100644 --- a/src/4D_api.cpp +++ b/src/4D_api.cpp @@ -1438,7 +1438,6 @@ int proj_errno_reset (const PJ *P) { proj_context_errno_set (pj_get_ctx ((PJ *) P), 0); errno = 0; - pj_errno = 0; return last_errno; } diff --git a/src/Makefile.am b/src/Makefile.am index e394b95b..4f3db3ed 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -209,7 +209,7 @@ libproj_la_SOURCES = \ \ aasincos.cpp adjlon.cpp \ dmstor.cpp auth.cpp \ - deriv.cpp ell_set.cpp ellps.cpp errno.cpp \ + deriv.cpp ell_set.cpp ellps.cpp \ factors.cpp fwd.cpp init.cpp inv.cpp \ list.cpp malloc.cpp mlfn.cpp mlfn.hpp msfn.cpp proj_mdist.cpp \ param.cpp phi2.cpp pr_list.cpp \ diff --git a/src/apps/cct.cpp b/src/apps/cct.cpp index e63a5fc2..92867b3a 100644 --- a/src/apps/cct.cpp +++ b/src/apps/cct.cpp @@ -360,7 +360,7 @@ int main(int argc, char **argv) { if (nullptr==P) { print (PJ_LOG_ERROR, "%s: Bad transformation arguments - (%s)\n '%s -h' for help", - o->progname, pj_strerrno (proj_errno(P)), o->progname); + o->progname, proj_errno_string (proj_errno(P)), o->progname); free (o); if (stdout != fout) fclose (fout); @@ -435,7 +435,7 @@ int main(int argc, char **argv) { if (HUGE_VAL==point.xyzt.x) { /* transformation error */ print (PJ_LOG_NONE, "# Record %d TRANSFORMATION ERROR: %s (%s)", - (int) o->record_index, buf, pj_strerrno (proj_errno(P))); + (int) o->record_index, buf, proj_errno_string (proj_errno(P))); proj_errno_restore (P, err); continue; } diff --git a/src/apps/cs2cs.cpp b/src/apps/cs2cs.cpp index 92e4441e..12e045bb 100644 --- a/src/apps/cs2cs.cpp +++ b/src/apps/cs2cs.cpp @@ -624,7 +624,7 @@ int main(int argc, char **argv) { if (!transformation) { emess(3, "cannot initialize transformation\ncause: %s", - pj_strerrno(pj_errno)); + proj_errno_string(proj_context_errno(nullptr))); } if (use_env_locale) { diff --git a/src/apps/gie.cpp b/src/apps/gie.cpp index 2fe854fa..b504b922 100644 --- a/src/apps/gie.cpp +++ b/src/apps/gie.cpp @@ -880,8 +880,8 @@ static int expect_failure_with_errno_message (int expected, int got) { banner (T.operation); fprintf (T.fout, "%s", T.op_ko? " -----\n": delim); fprintf (T.fout, " FAILURE in %s(%d):\n", opt_strip_path (T.curr_file), (int) F->lineno); - fprintf (T.fout, " got errno %s (%d): %s\n", err_const_from_errno(got), got, pj_strerrno (got)); - fprintf (T.fout, " expected %s (%d): %s", err_const_from_errno(expected), expected, pj_strerrno (expected)); + fprintf (T.fout, " got errno %s (%d): %s\n", err_const_from_errno(got), got, proj_errno_string (got)); + fprintf (T.fout, " expected %s (%d): %s", err_const_from_errno(expected), expected, proj_errno_string (expected)); fprintf (T.fout, "\n"); return 1; } @@ -934,7 +934,7 @@ Tell GIE what to expect, when transforming the ACCEPTed input /* Otherwise, it's a true failure */ banner (T.operation); errmsg (3, "%sInvalid operation definition in line no. %d:\n %s (errno=%s/%d)\n", - delim, (int) T.operation_lineno, pj_strerrno(proj_errno(T.P)), + delim, (int) T.operation_lineno, proj_errno_string (proj_errno(T.P)), err_const_from_errno (proj_errno(T.P)), proj_errno(T.P) ); return another_failing_failure (); @@ -1186,7 +1186,7 @@ static int list_err_codes (void) { if (9999==lookup[i].the_errno) break; fprintf (T.fout, "%25s (%2.2d): %s\n", lookup[i].the_err_const + 8, - lookup[i].the_errno, pj_strerrno(lookup[i].the_errno)); + lookup[i].the_errno, proj_errno_string (lookup[i].the_errno)); } return 0; } diff --git a/src/apps/proj.cpp b/src/apps/proj.cpp index 8bfd99a3..a5c917f6 100644 --- a/src/apps/proj.cpp +++ b/src/apps/proj.cpp @@ -250,10 +250,8 @@ static void vprocess(FILE *fid) { if (postscale) { dat_xy.x *= fscale; dat_xy.y *= fscale; } } - /* For some reason pj_errno does not work as expected in some */ - /* versions of Visual Studio, so using pj_get_errno_ref instead */ - if (*pj_get_errno_ref()) { - emess(-1, pj_strerrno(*pj_get_errno_ref())); + if (proj_context_errno(nullptr)) { + emess(-1, proj_errno_string(proj_context_errno(nullptr))); continue; } @@ -477,7 +475,7 @@ int main(int argc, char **argv) { } if (!(Proj = pj_init(pargc, pargv))) emess(3,"projection initialization failure\ncause: %s", - pj_strerrno(pj_errno)); + proj_errno_string(proj_context_errno(nullptr))); if (!proj_angular_input(Proj, PJ_FWD)) { emess(3, "can't initialize operations that take non-angular input coordinates"); diff --git a/src/errno.cpp b/src/errno.cpp deleted file mode 100644 index 4f3119b3..00000000 --- a/src/errno.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* For full ANSI compliance of global variable */ - -#include "proj.h" -#include "proj_internal.h" - -int pj_errno = 0; - -/************************************************************************/ -/* pj_get_errno_ref() */ -/************************************************************************/ - -int *pj_get_errno_ref() - -{ - return &pj_errno; -} - -/* end */ diff --git a/src/internal.cpp b/src/internal.cpp index c1ffc408..175ffa9b 100644 --- a/src/internal.cpp +++ b/src/internal.cpp @@ -415,7 +415,6 @@ to that context. if( err == 0 ) return; errno = err; - pj_errno = err; } /* logging */ diff --git a/src/lib_proj.cmake b/src/lib_proj.cmake index 1361294d..7ca7f3a4 100644 --- a/src/lib_proj.cmake +++ b/src/lib_proj.cmake @@ -217,7 +217,6 @@ set(SRC_LIBPROJ_CORE dmstor.cpp ell_set.cpp ellps.cpp - errno.cpp factors.cpp fwd.cpp gauss.cpp diff --git a/src/pipeline.cpp b/src/pipeline.cpp index 80ee0397..56a80848 100644 --- a/src/pipeline.cpp +++ b/src/pipeline.cpp @@ -533,7 +533,7 @@ PJ *OPERATION(pipeline,0) { int err_to_report = proj_errno(P); if (0==err_to_report) err_to_report = PJD_ERR_MALFORMED_PIPELINE; - proj_log_error (P, "Pipeline: Bad step definition: %s (%s)", current_argv[0], pj_strerrno (err_to_report)); + proj_log_error (P, "Pipeline: Bad step definition: %s (%s)", current_argv[0], proj_errno_string (err_to_report)); return destructor (P, err_to_report); /* ERROR: bad pipeline def */ } next_step->parent = P; diff --git a/src/proj_internal.h b/src/proj_internal.h index d57e87a2..7e41f0f9 100644 --- a/src/proj_internal.h +++ b/src/proj_internal.h @@ -921,7 +921,6 @@ PJ_LP pj_generic_inverse_2d(PJ_XY xy, PJ *P, PJ_LP lpInitial); extern char const PROJ_DLL pj_release[]; /* global release id string */ -PROJ_DLL extern int pj_errno; /* global error return code */ #ifndef PROJ_INTERNAL_H /* replaced by enum proj_log_level in proj_internal.h */ @@ -959,8 +958,6 @@ void PROJ_DLL pj_dalloc(void *); void PROJ_DLL *pj_calloc (size_t n, size_t size); void PROJ_DLL *pj_dealloc (void *ptr); char PROJ_DLL *pj_strdup(const char *str); -char PROJ_DLL *pj_strerrno(int); -int PROJ_DLL *pj_get_errno_ref(void); const char PROJ_DLL *pj_get_release(void); void PROJ_DLL pj_acquire_lock(void); void PROJ_DLL pj_release_lock(void); diff --git a/src/strerrno.cpp b/src/strerrno.cpp index 1c8673d0..3d0131c6 100644 --- a/src/strerrno.cpp +++ b/src/strerrno.cpp @@ -1,4 +1,4 @@ -/* list of projection system pj_errno values */ +/* list of projection system errno values */ #include #include @@ -74,10 +74,11 @@ pj_err_list[] = { "network error", /* -62 */ /* When adding error messages, remember to update ID defines in - projects.h, and transient_error array in pj_transform */ + src/proj_internal.h and src/apps/gie.cpp */ }; -char *pj_strerrno(int err) { + +const char* proj_errno_string(int err) { const int max_error = 9999; static char note[50]; size_t adjusted_err; @@ -98,7 +99,7 @@ char *pj_strerrno(int err) { #endif } - /* PROJ.4 error codes are negative: -1 to -9999 */ + /* PROJ error codes are negative: -1 to -9999 */ adjusted_err = err < -max_error ? max_error : -err - 1; if (adjusted_err < (sizeof(pj_err_list) / sizeof(char *))) return (char *)pj_err_list[adjusted_err]; @@ -107,7 +108,3 @@ char *pj_strerrno(int err) { (err > -max_error) ? err: -max_error); return note; } - -const char* proj_errno_string(int err) { - return pj_strerrno(err); -} -- cgit v1.2.3