{
return lwfree_var(mem);
}
+
+/*
+ * Removes trailing zeros and dot for a %f formatted number.
+ * Modifies input.
+ */
+void
+trim_trailing_zeros(char *str)
+{
+ char *ptr, *totrim=NULL;
+ int len;
+ int i;
+
+ //lwnotice("input: %s", str);
+
+ ptr = strchr(str, '.');
+ if ( ! ptr ) return; // no dot, no decimal digits
+
+ //lwnotice("ptr: %s", ptr);
+
+ len = strlen(ptr);
+ for (i=len-1; i; i--)
+ {
+ if ( ptr[i] != '0' ) break;
+ totrim=&ptr[i];
+ }
+ if ( totrim )
+ {
+ if ( ptr == totrim-1 ) *ptr = '\0';
+ else *totrim = '\0';
+ }
+
+ //lwnotice("output: %s", str);
+}
extern void *lwrealloc(void *mem, size_t size);
extern void lwfree(void *mem);
+/* Utilities */
+extern void trim_trailing_zeros(char *num);
+
#endif // !defined _LIBLWGEOM_H