summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Johnson <ajohnson@redneon.com>2018-11-24 18:36:26 +1030
committerAdrian Johnson <ajohnson@redneon.com>2018-12-31 12:45:06 +1030
commit3a0670e03c6a93fda764878697a78e3b966ef1f1 (patch)
tree707076123a2c47fa2a4034cd6e189fc93abd4c6d
parent4804d073e6e197945ffe1852f0407e4364bc71be (diff)
tag_attributes: Allow decimal points in non decimal point locales
Issue #347
-rw-r--r--src/cairo-tag-attributes.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/cairo-tag-attributes.c b/src/cairo-tag-attributes.c
index 44b1147fb..f4ad501d3 100644
--- a/src/cairo-tag-attributes.c
+++ b/src/cairo-tag-attributes.c
@@ -217,9 +217,28 @@ static const char *
parse_float (const char *p, double *d)
{
int n;
+ const char *start = p;
+ cairo_bool_t has_decimal_point = FALSE;
- if (sscanf(p, "%lf%n", d, &n) > 0)
- return p + n;
+ while (*p) {
+ if (*p == '.' || *p == ']' || _cairo_isspace (*p))
+ break;
+ p++;
+ }
+
+ if (*p == '.')
+ has_decimal_point = TRUE;
+
+ if (has_decimal_point) {
+ char *end;
+ *d = _cairo_strtod (start, &end);
+ if (end)
+ return end;
+
+ } else {
+ if (sscanf(start, "%lf%n", d, &n) > 0)
+ return start + n;
+ }
return NULL;
}