fontconfig: Branch 'master'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 test/test-conf.c |   25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

New commits:
commit 921ede9f460fb661146182809557a1da2dd7afd7
Author: Ben Wagner <bungeman@xxxxxxxxxxxx>
Date:   Tue Dec 15 16:30:14 2020 -0500

    Fix test-conf string to integer conversion.
    
    The test-conf build_pattern attempted to convert known constant strings
    into integer values. However, it did so by always converting the string
    value to an integer if possible and then complaining if the key wasn't
    of the expected type. This lead to error messages on "style": "Regular"
    since "Regular" was recognized as "weight".
    
    Instead, only attempt conversion from string to integer if the key is
    the name of an object which can take an integer type. This eliminates
    the spurious non-fatal errors reported when parsing
    test-90-synthetic.json.
    
    This also fixes an issue where the created value was given the type of
    the object found, but the integer field was assigned. Instead, check
    that the object type can take an integer and always set the value type
    to integer.

diff --git a/test/test-conf.c b/test/test-conf.c
index 6097983..288bb5b 100644
--- a/test/test-conf.c
+++ b/test/test-conf.c
@@ -69,22 +69,25 @@ build_pattern (json_object *obj)
 	}
 	else if (json_object_get_type (iter.val) == json_type_string)
 	{
-		const FcConstant *c = FcNameGetConstant ((const FcChar8 *) json_object_get_string (iter.val));
-	    FcBool b;
-
-	    if (c)
+	    const FcObjectType *o = FcNameGetObjectType (iter.key);
+	    if (o && (o->type == FcTypeRange || o->type == FcTypeDouble || o->type == FcTypeInteger))
 	    {
-		const FcObjectType *o;
-
+		const FcConstant *c = FcNameGetConstant ((const FcChar8 *) json_object_get_string (iter.val));
+		if (!c) {
+		    fprintf (stderr, "E: value is not a known constant\n");
+		    fprintf (stderr, "   key: %s\n", iter.key);
+		    fprintf (stderr, "   val: %s\n", json_object_get_string (iter.val));
+		    continue;
+		}
 		if (strcmp (c->object, iter.key) != 0)
 		{
-		    fprintf (stderr, "E: invalid object type for const\n");
-		    fprintf (stderr, "   actual result: %s\n", iter.key);
-		    fprintf (stderr, "   expected result: %s\n", c->object);
+		    fprintf (stderr, "E: value is a constant of different object\n");
+		    fprintf (stderr, "   key: %s\n", iter.key);
+		    fprintf (stderr, "   val: %s\n", json_object_get_string (iter.val));
+		    fprintf (stderr, "   key implied by value: %s\n", c->object);
 		    continue;
 		}
-		o = FcNameGetObjectType (c->object);
-		v.type = o->type;
+		v.type = FcTypeInteger;
 		v.u.i = c->value;
 	    }
 	    else if (strcmp (json_object_get_string (iter.val), "DontCare") == 0)
_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/fontconfig



[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux