PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ trim_trailing_zeros()

static void trim_trailing_zeros ( char *  str)
static

Definition at line 446 of file lwprint.c.

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

References LWDEBUGF.

Referenced by lwprint_double().

Here is the caller graph for this function: