From: Sandro Santilli Date: Fri, 16 Mar 2012 11:58:49 +0000 (+0000) Subject: Do not take PROJ4 errno value as a sign of error (#1580, #1690) X-Git-Tag: 2.0.0beta4~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a05c53ad59230b26d668129f74ebf5fbe56c1ec0;p=postgis Do not take PROJ4 errno value as a sign of error (#1580, #1690) Dejavu... git-svn-id: http://svn.osgeo.org/postgis/trunk@9507 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/postgis/lwgeom_transform.c b/postgis/lwgeom_transform.c index a9abd1fbc..23fe5c53d 100644 --- a/postgis/lwgeom_transform.c +++ b/postgis/lwgeom_transform.c @@ -107,7 +107,8 @@ Datum transform_geom(PG_FUNCTION_ARGS) text *input_proj4_text; text *output_proj4_text; int32 result_srid ; - int* pj_errno_ref; + char *pj_errstr; + result_srid = PG_GETARG_INT32(3); @@ -121,7 +122,7 @@ Datum transform_geom(PG_FUNCTION_ARGS) if (gserialized_get_srid(geom) == SRID_UNKNOWN) { pfree(geom); - elog(ERROR,"tranform: source SRID = %d",SRID_UNKNOWN); + elog(ERROR,"transform_geom: source SRID = %d",SRID_UNKNOWN); PG_RETURN_NULL(); } @@ -138,30 +139,38 @@ Datum transform_geom(PG_FUNCTION_ARGS) /* make input and output projection objects */ input_pj = lwproj_from_string(input_proj4); - - pj_errno_ref = pj_get_errno_ref(); - if ( (input_pj == NULL) || (*pj_errno_ref)) + if ( input_pj == NULL ) { + pj_errstr = pj_strerrno(*pj_get_errno_ref()); + if ( ! pj_errstr ) pj_errstr = ""; + /* we need this for error reporting */ /* pfree(input_proj4); */ - pfree(output_proj4); pfree(geom); - elog(ERROR, "transform: couldn't parse proj4 input string: '%s': %s", input_proj4, pj_strerrno(*pj_errno_ref)); + + elog(ERROR, + "transform_geom: could not parse proj4 string '%s' %s", + input_proj4, pj_errstr); PG_RETURN_NULL(); } pfree(input_proj4); output_pj = lwproj_from_string(output_proj4); - pj_errno_ref = pj_get_errno_ref(); - if ((output_pj == NULL)|| (*pj_errno_ref)) + if ( output_pj == NULL ) { + pj_errstr = pj_strerrno(*pj_get_errno_ref()); + if ( ! pj_errstr ) pj_errstr = ""; + /* we need this for error reporting */ /* pfree(output_proj4); */ pj_free(input_pj); pfree(geom); - elog(ERROR, "transform: couldn't parse proj4 output string: '%s': %s", output_proj4, pj_strerrno(*pj_errno_ref)); + + elog(ERROR, + "transform_geom: couldn't parse proj4 output string: '%s': %s", + output_proj4, pj_errstr); PG_RETURN_NULL(); } pfree(output_proj4);