Opened 15 years ago

Closed 15 years ago

#720 closed defect (fixed)

G_trim_decimal(): don't chop 0s on strings ending in e+20

Reported by: hamish Owned by: grass-dev@…
Priority: critical Milestone: 6.4.0
Component: LibGIS Version: 6.4.0 RCs
Keywords: G_trim_decimal Cc:
CPU: All Platform: All



G_trim_decimal() will blindly chop away 0s after the decimal point, converting ,for example, a string ending in e+20 into e+2. :-(

I guess 'e' needs to be the trigger character; if found we have a choice to either just return the original string or perform heroics such as:



thanks, Hamish

Change History (3)

comment:1 by hamish, 15 years ago


Index: lib/gis/trim_dec.c
--- lib/gis/trim_dec.c  (revision 38754)
+++ lib/gis/trim_dec.c  (working copy)
@@ -14,6 +14,7 @@
  * \date 1999-2008
+#include <string.h>
 #include <grass/gis.h>
@@ -30,6 +31,10 @@
     char *mark;
+    /* don't trim e+20 into e+2 */
+    if( strchr(buf, 'e') || strchr(buf, 'E') )
+       return 0;
     /* find the . */
     while (*buf != '.')
        if (*buf++ == 0)


comment:2 by hamish, 15 years ago

there has been no feedback so I have applied this patch in 6.5svn and trunk. I'd like to backport it to 6.4 as well but won't without further testing.

comment:3 by hamish, 15 years ago

Resolution: fixed
Status: newclosed

backported to relbr64 in r39045. still no feedback, hope there are no problems with it.


Note: See TracTickets for help on using tickets.