[postgis-tickets] [SCM] PostGIS branch master updated. 0752db58ac990161981de417248edb918318f17f

git at osgeo.org git at osgeo.org
Mon Jan 27 01:28:54 PST 2020


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "PostGIS".

The branch, master has been updated
       via  0752db58ac990161981de417248edb918318f17f (commit)
      from  7a54134c70582a52676c1c4fae709db9e2a29c9a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 0752db58ac990161981de417248edb918318f17f
Author: Raúl Marín <git at rmr.ninja>
Date:   Fri Jan 24 18:55:44 2020 +0100

    lwprint: Avoid using snprintf
    
    It can be simplified with simple pointer writes
    
    Closes https://github.com/postgis/postgis/pull/539
    References #4543

diff --git a/liblwgeom/lwprint.c b/liblwgeom/lwprint.c
index 5f9fe57..031c64f 100644
--- a/liblwgeom/lwprint.c
+++ b/liblwgeom/lwprint.c
@@ -492,15 +492,17 @@ lwdecimal_length(const double d)
 int
 lwprint_double(double d, uint32_t maxdd, char *buf, size_t bufsize)
 {
+	assert(bufsize >= OUT_DOUBLE_BUFFER_SIZE);
+
 	int length;
 	double ad = fabs(d);
 	if (ad <= FP_TOLERANCE)
 	{
-		return snprintf(buf, bufsize, "0");
+		buf[0] = '0';
+		buf[1] = '\0';
+		return 1;
 	}
 
-	assert(bufsize >= OUT_DOUBLE_BUFFER_SIZE);
-
 	if (ad >= OUT_MAX_DOUBLE)
 	{
 		/* Compat with previous releases: The precision for exponential notation

-----------------------------------------------------------------------

Summary of changes:
 liblwgeom/lwprint.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)


hooks/post-receive
-- 
PostGIS


More information about the postgis-tickets mailing list