PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ trim_trailing_zeros()

void trim_trailing_zeros ( char *  num)

Definition at line 254 of file lwutil.c.

References LWDEBUGF.

Referenced by assvg_point_buf(), pointArray_svg_abs(), pointArray_svg_rel(), pointArray_to_geojson(), pointArray_toGML2(), pointArray_toGML3(), and pointArray_toX3D3().

255 {
256  char *ptr, *totrim=NULL;
257  int len;
258  int i;
259 
260  LWDEBUGF(3, "input: %s", str);
261 
262  ptr = strchr(str, '.');
263  if ( ! ptr ) return; /* no dot, no decimal digits */
264 
265  LWDEBUGF(3, "ptr: %s", ptr);
266 
267  len = strlen(ptr);
268  for (i=len-1; i; i--)
269  {
270  if ( ptr[i] != '0' ) break;
271  totrim=&ptr[i];
272  }
273  if ( totrim )
274  {
275  if ( ptr == totrim-1 ) *ptr = '\0';
276  else *totrim = '\0';
277  }
278 
279  LWDEBUGF(3, "output: %s", str);
280 }
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
Here is the caller graph for this function: