Make FC_DBG_OBJTYPES debug messages into warnings
authorBehdad Esfahbod <behdad@behdad.org>
Wed, 2 Jan 2013 01:52:14 +0000 (19:52 -0600)
committerBehdad Esfahbod <behdad@behdad.org>
Wed, 2 Jan 2013 02:19:53 +0000 (20:19 -0600)
And remove FC_DBG_OBJTYPES since it has no use now.

src/fcdbg.c
src/fcint.h
src/fcpat.c

index 20fc6c8..e8cbe32 100644 (file)
 #include <stdlib.h>
 
 static void
-_FcValuePrint (const FcValue v)
+_FcValuePrintFile (FILE *f, const FcValue v)
 {
     switch (v.type) {
     case FcTypeVoid:
-       printf ("<void>");
+       fprintf (f, "<void>");
        break;
     case FcTypeInteger:
-       printf ("%d(i)", v.u.i);
+       fprintf (f, "%d(i)", v.u.i);
        break;
     case FcTypeDouble:
-       printf ("%g(f)", v.u.d);
+       fprintf (f, "%g(f)", v.u.d);
        break;
     case FcTypeString:
-       printf ("\"%s\"", v.u.s);
+       fprintf (f, "\"%s\"", v.u.s);
        break;
     case FcTypeBool:
-       printf ("%s", v.u.b ? "True" : "False");
+       fprintf (f, "%s", v.u.b ? "True" : "False");
        break;
     case FcTypeMatrix:
-       printf ("[%g %g; %g %g]", v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy);
+       fprintf (f, "[%g %g; %g %g]", v.u.m->xx, v.u.m->xy, v.u.m->yx, v.u.m->yy);
        break;
     case FcTypeCharSet:        /* XXX */
-       FcCharSetPrint (v.u.c);
+       if (f == stdout)
+           FcCharSetPrint (v.u.c);
        break;
     case FcTypeLangSet:
        FcLangSetPrint (v.u.l);
        break;
     case FcTypeFTFace:
-       printf ("face");
+       fprintf (f, "face");
        break;
     }
 }
 
 void
+FcValuePrintFile (FILE *f, const FcValue v)
+{
+    fprintf (f, " ");
+    _FcValuePrintFile (f, v);
+}
+
+void
 FcValuePrint (const FcValue v)
 {
     printf (" ");
-    _FcValuePrint (v);
+    _FcValuePrintFile (stdout, v);
 }
 
 void
@@ -74,7 +82,7 @@ FcValuePrintWithPosition (const FcValue v, FcBool show_pos_mark)
        printf (" [insert here] ");
     else
        printf (" ");
-    _FcValuePrint (v);
+    _FcValuePrintFile (stdout, v);
 }
 
 static void
index 68074f0..76b95ca 100644 (file)
@@ -86,7 +86,6 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
 #define FC_DBG_SCANV   256
 #define FC_DBG_CONFIG  1024
 #define FC_DBG_LANGSET 2048
-#define FC_DBG_OBJTYPES        4096
 
 #define _FC_ASSERT_STATIC1(_line, _cond) typedef int _static_assert_on_line_##_line##_failed[(_cond)?1:-1]
 #define _FC_ASSERT_STATIC0(_line, _cond) _FC_ASSERT_STATIC1 (_line, (_cond))
@@ -703,6 +702,10 @@ FcPrivate FcChar16 *
 FcCharSetGetNumbers(const FcCharSet *c);
 
 /* fcdbg.c */
+
+FcPrivate void
+FcValuePrintFile (FILE *f, const FcValue v);
+
 FcPrivate void
 FcValuePrintWithPosition (const FcValue v, FcBool show_pos_mark);
 
index 5d94295..0aab7a0 100644 (file)
@@ -553,12 +553,10 @@ FcPatternObjectListAdd (FcPattern *p,
     {
        if (!FcObjectValidType (object, l->value.type))
        {
-           if (FcDebug() & FC_DBG_OBJTYPES)
-           {
-               printf ("FcPattern object %s does not accept value ",
-                       FcObjectName (object));
-               FcValuePrint (l->value);
-           }
+           fprintf (stderr,
+                    "Fontconfig warning: FcPattern object %s does not accept value", FcObjectName (object));
+           FcValuePrintFile (stderr, l->value);
+           fprintf (stderr, "\n");
            goto bail0;
        }
     }
@@ -613,12 +611,11 @@ FcPatternObjectAddWithBinding  (FcPattern *p,
      */
     if (!FcObjectValidType (object, value.type))
     {
-       if (FcDebug() & FC_DBG_OBJTYPES)
-       {
-           printf ("FcPattern object %s does not accept value ",
-                   FcObjectName (object));
-           FcValuePrint (value);
-       }
+       fprintf (stderr,
+                "Fontconfig warning: FcPattern object %s does not accept value",
+                FcObjectName (object));
+       FcValuePrintFile (stderr, value);
+       fprintf (stderr, "\n");
        goto bail1;
     }