#ifdef HAVE_MATH_H
#include <math.h>
#endif
-#include <glib.h>
#include <string.h>
+#include "degrees_converters.h"
#define DEGREE_SYMBOL "\302\260"
tmp = (tmp - val_d) * 60;
val_m = (gint)tmp;
- /* Minutes */
+ /* Seconds */
val_s = (tmp - val_m) * 60;
/* Format */
gdouble value;
ptr = strpbrk (endptr, "0123456789,.");
if (ptr != NULL) {
- value = g_strtod((const gchar *)ptr, (gchar **)&endptr);
- nbFloat++;
+ const gchar *tmpptr = endptr;
+ value = g_strtod((const gchar *)ptr, (gchar **)&endptr);
+ // Detect when endptr hasn't changed (which may occur if no conversion took place)
+ // particularly if the last character is a ',' or there are multiple '.'s like '5.5.'
+ if ( endptr == tmpptr )
+ break;
+ nbFloat++;
switch(nbFloat) {
case 1:
d = value;
case 3:
s = value;
break;
+ default: break;
}
}
} while (ptr != NULL && endptr != NULL);