PostGIS  2.5.0dev-r@@SVN_REVISION@@

◆ trim_trailing_zeros()

static void trim_trailing_zeros ( char *  str)
static

Definition at line 444 of file lwprint.c.

References LWDEBUGF.

Referenced by lwprint_double().

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