Don't warn if an unknown element is used in an expression
authorBehdad Esfahbod <behdad@behdad.org>
Mon, 31 Dec 2012 01:08:42 +0000 (19:08 -0600)
committerBehdad Esfahbod <behdad@behdad.org>
Mon, 31 Dec 2012 01:08:42 +0000 (19:08 -0600)
The type will be resolved at runtime...

For example, we can do this now without getting a warning:

<match target="font">
  <test name="scalable" compare="eq">
    <bool>false</bool>
  </test>
  <edit name="pixelsizefixupfactor" mode="assign">
    <divide>
      <name target="pattern">pixelsize</name>
      <name target="font"   >pixelsize</name>
    </divide>
  </edit>
  <edit name="matrix" mode="assign">
    <times>
      <name>matrix</name>
      <matrix>
        <name>pixelsizefixupfactor</name> <double>0</double>
        <double>0</double> <name>pixelsizefixupfactor</name>
       </matrix>
    </times>
  </edit>
  <edit name="size" mode="assign">
    <divide>
      <name>size</name>
      <name>pixelsizefixupfactor</name>
    </divide>
  </edit>
</match>

Previously the last edit was generating:

Fontconfig warning: "/home/behdad/.local/etc/fonts/conf.d/00-scale-bitmap-fonts.conf", line 29: saw unknown, expected number

src/fcxml.c

index d31caf5..cf9c8dd 100644 (file)
@@ -594,6 +594,10 @@ FcTypecheckValue (FcConfigParse *parse, FcType value, FcType type)
            return;
        if (type == (FcType) -1)
            return;
+       /* It's perfectly fine to use user-define elements in expressions,
+        * so don't warn in that case. */
+       if (value == (FcType) -1)
+           return;
        FcConfigMessage (parse, FcSevereWarning, "saw %s, expected %s",
                         FcTypeName (value), FcTypeName (type));
     }