4a5b52
From 198358dd8ff858c9e36531a7406ccb2246ae77b7 Mon Sep 17 00:00:00 2001
4a5b52
From: Akira TAGOH <akira@tagoh.org>
4a5b52
Date: Mon, 12 Mar 2018 11:49:58 +0900
4a5b52
Subject: [PATCH] Allow the constant names in the range
4a5b52
4a5b52
https://bugs.freedesktop.org/show_bug.cgi?id=105415
4a5b52
---
4a5b52
 src/fcname.c | 34 +++++++++++++++++++++++++++++-----
4a5b52
 1 file changed, 29 insertions(+), 5 deletions(-)
4a5b52
4a5b52
diff --git a/src/fcname.c b/src/fcname.c
4a5b52
index 79e413e..15fb659 100644
4a5b52
--- a/src/fcname.c
4a5b52
+++ b/src/fcname.c
4a5b52
@@ -330,13 +330,37 @@ FcNameConvert (FcType type, FcChar8 *string)
4a5b52
     case FcTypeRange:
4a5b52
 	if (sscanf ((char *) string, "[%lg %lg]", &b, &e) != 2)
4a5b52
 	{
4a5b52
-	    v.u.d = strtod ((char *) string, &p);
4a5b52
-	    if (p != NULL && p[0] != 0)
4a5b52
+	    char *sc, *ec;
4a5b52
+	    size_t len = strlen ((const char *) string);
4a5b52
+	    int si, ei;
4a5b52
+
4a5b52
+	    sc = malloc (len);
4a5b52
+	    ec = malloc (len);
4a5b52
+	    if (sc && ec && sscanf ((char *) string, "[%s %[^]]]", sc, ec) == 2)
4a5b52
 	    {
4a5b52
-		v.type = FcTypeVoid;
4a5b52
-		break;
4a5b52
+		if (FcNameConstant ((const FcChar8 *) sc, &si) &&
4a5b52
+		    FcNameConstant ((const FcChar8 *) ec, &ei))
4a5b52
+		    v.u.r =  FcRangeCreateDouble (si, ei);
4a5b52
+		else
4a5b52
+		    goto bail1;
4a5b52
+	    }
4a5b52
+	    else
4a5b52
+	    {
4a5b52
+	    bail1:
4a5b52
+		v.type = FcTypeDouble;
4a5b52
+		if (FcNameConstant (string, &si))
4a5b52
+		{
4a5b52
+		    v.u.d = (double) si;
4a5b52
+		} else {
4a5b52
+		    v.u.d = strtod ((char *) string, &p);
4a5b52
+		    if (p != NULL && p[0] != 0)
4a5b52
+			v.type = FcTypeVoid;
4a5b52
+		}
4a5b52
 	    }
4a5b52
-	    v.type = FcTypeDouble;
4a5b52
+	    if (sc)
4a5b52
+		free (sc);
4a5b52
+	    if (ec)
4a5b52
+		free (ec);
4a5b52
 	}
4a5b52
 	else
4a5b52
 	    v.u.r = FcRangeCreateDouble (b, e);
4a5b52
-- 
4a5b52
2.14.3
4a5b52