[libgda: 4/5] fixed: can't parse string point(123,-2.23423)
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda: 4/5] fixed: can't parse string point(123,-2.23423)
- Date: Mon, 4 Oct 2021 04:14:05 +0000 (UTC)
commit 28368adbd4351906563fd32baa5f6c2a633daf3a
Author: taozuhong <taozuhong gmail com>
Date: Thu Sep 30 17:27:53 2021 +0800
fixed: can't parse string point(123,-2.23423)
libgda/gda-value.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index e7b87d1ea..f142e6e5e 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -194,12 +194,15 @@ set_from_string (GValue *value, const gchar *as_string)
}
else if (type == GDA_TYPE_GEOMETRIC_POINT) {
GdaGeometricPoint* point = gda_geometric_point_new ();
- as_string++;
- gda_geometric_point_set_x (point, g_ascii_strtod (as_string, NULL));
- as_string = strchr (as_string, ',');
- as_string++;
- gda_geometric_point_set_y (point, g_ascii_strtod (as_string, NULL));
-
+ double x = 0, y = 0;
+ gchar * as_start = strchr (as_string, '(');
+ if (NULL != as_start) {
+ sscanf (as_start, "(%lf,%lf)", &x, &y);
+ } else {
+ sscanf (as_string, "%lf,%lf", &x, &y);
+ }
+ gda_geometric_point_set_x (point, x);
+ gda_geometric_point_set_y (point, y);
gda_value_set_geometric_point (value, point);
gda_geometric_point_free (point);
retval = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]