PostGIS  3.0.6dev-r@@SVN_REVISION@@

◆ trim_trailing_zeros()

static void trim_trailing_zeros ( char *  str)
static

Definition at line 448 of file lwprint.c.

449 {
450  char *ptr, *totrim = NULL;
451  int len;
452  int i;
453 
454  LWDEBUGF(3, "input: %s", str);
455 
456  ptr = strchr(str, '.');
457  if (!ptr) return; /* no dot, no decimal digits */
458 
459  LWDEBUGF(3, "ptr: %s", ptr);
460 
461  len = strlen(ptr);
462  for (i = len - 1; i; i--)
463  {
464  if (ptr[i] != '0') break;
465  totrim = &ptr[i];
466  }
467  if (totrim)
468  {
469  if (ptr == totrim - 1)
470  *ptr = '\0';
471  else
472  *totrim = '\0';
473  }
474 
475  LWDEBUGF(3, "output: %s", str);
476 }
#define str(s)
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88

References LWDEBUGF, and str.

Referenced by lwprint_double().

Here is the caller graph for this function: