[cairo-commit] src/cairo-tag-attributes.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Dec 31 02:38:00 UTC 2018


 src/cairo-tag-attributes.c |   23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

New commits:
commit 3a0670e03c6a93fda764878697a78e3b966ef1f1
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat Nov 24 18:36:26 2018 +1030

    tag_attributes: Allow decimal points in non decimal point locales
    
    Issue #347

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;
 }


More information about the cairo-commit mailing list