diff options
| author | Thomas Knudsen <busstoptaktik@users.noreply.github.com> | 2017-11-20 13:20:02 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-11-20 13:20:02 +0100 |
| commit | 5f1522ad7652e562f98328b05d905c407bab99e9 (patch) | |
| tree | f8a73c0c5eb53ef4ba05eb5fd0ca5c9f0fa5d882 /src/proj_4D_api.c | |
| parent | 3d6f36a2e10d103727a072d160fcf724daa871d5 (diff) | |
| download | PROJ-5f1522ad7652e562f98328b05d905c407bab99e9.tar.gz PROJ-5f1522ad7652e562f98328b05d905c407bab99e9.zip | |
Replace pj_ell_set with reimplementation... (#675)
* Replace pj_ell_set with reimplementation supporting ellipsoid inheritance
* remove unreachable code from pj_ell_set.c
* Swap steps, so ellps args are read first, in accordance with historical behaviour
* Add ellipsoid tests to CI targets
* Reduce some optimistic tolerances
OS/X appears to have a slightly off float handling, resulting in differences at the nanometer level. Switching to 10 nm.
Diffstat (limited to 'src/proj_4D_api.c')
| -rw-r--r-- | src/proj_4D_api.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/src/proj_4D_api.c b/src/proj_4D_api.c index 7196b90c..4f044101 100644 --- a/src/proj_4D_api.c +++ b/src/proj_4D_api.c @@ -520,37 +520,33 @@ int proj_errno (PJ *P) { } /*****************************************************************************/ -void proj_errno_set (PJ *P, int err) { +int proj_errno_set (PJ *P, int err) { /****************************************************************************** - Sets errno at the context and bubble it up to the thread local errno + Set context-errno, bubble it up to the thread local errno, return err ******************************************************************************/ /* Use proj_errno_reset to explicitly clear the error status */ if (0==err) - return; + return 0; /* For P==0 err goes to the default context */ proj_context_errno_set (pj_get_ctx (P), err); errno = err; - return; + return err; } /*****************************************************************************/ -void proj_errno_restore (PJ *P, int err) { +int proj_errno_restore (PJ *P, int err) { /****************************************************************************** - Reduce some mental impedance in the canonical reset/restore use case: - Basically, proj_errno_restore() is a synonym for proj_errno_set(), - but the use cases are very different (_set: indicate an error to higher - level user code, _restore: pass previously set error indicators in case - of no errors at this level). - - Hence, although the inner working is identical, we provide both options, - to avoid some rather confusing real world code. + Use proj_errno_restore when the current function succeeds, but the + error flag was set on entry, and stored/reset using proj_errno_reset + in order to monitor for new errors. See usage example under proj_errno_reset () ******************************************************************************/ if (0==err) - return; + return 0; proj_errno_set (P, err); + return 0; } /*****************************************************************************/ @@ -562,17 +558,24 @@ int proj_errno_reset (PJ *P) { Returns the previous value of the errno, for convenient reset/restore operations: - void foo (PJ *P) { + int foo (PJ *P) { + // errno may be set on entry, but we need to reset it to be able to + // check for errors from "do_something_with_P(P)" int last_errno = proj_errno_reset (P); + // local failure + if (0==P) + return proj_errno_set (P, 42); + + // call to function that may fail do_something_with_P (P); - // failure - keep latest error status + // failure in do_something_with_P? - keep latest error status if (proj_errno(P)) - return; - // success - restore previous error status - proj_errno_restore (P, last_errno); - return; + return proj_errno (P); + + // success - restore previous error status, return 0 + return proj_errno_restore (P, last_errno); } ******************************************************************************/ int last_errno; |
