Add FcTypeUnknown to FcType to avoid comparison of constant -1
authorAkira TAGOH <akira@tagoh.org>
Fri, 28 Jun 2013 06:04:11 +0000 (15:04 +0900)
committerAkira TAGOH <akira@tagoh.org>
Fri, 28 Jun 2013 06:04:11 +0000 (15:04 +0900)
This change reverts 9acc14c34a372b54f9075ec3611588298fb2a501
because it doesn't work as expected when building
with -fshort-enums which is default for older arms ABIs

Thanks for pointing this out, Thomas Klausner, Valery Ushakov, and Martin Husemann

fontconfig/fcprivate.h
fontconfig/fontconfig.h
src/fccfg.c
src/fcdbg.c
src/fcint.h
src/fclist.c
src/fcname.c
src/fcobjs.c
src/fcpat.c
src/fcxml.c

index 18b8c08..210c1d8 100644 (file)
@@ -48,8 +48,9 @@
        __o__ = va_arg (va, const char *);                          \
        if (!__o__)                                                 \
            break;                                                  \
-       __v__.type = va_arg (va, FcType);                           \
+       __v__.type = va_arg (va, int);                              \
        switch (__v__.type) {                                       \
+       case FcTypeUnknown:                                         \
        case FcTypeVoid:                                            \
            goto _FcPatternVapBuild_bail1;                          \
        case FcTypeInteger:                                         \
index 422187b..39d1b1b 100644 (file)
@@ -185,6 +185,7 @@ typedef int         FcBool;
 #define FC_LCD_LEGACY      3
 
 typedef enum _FcType {
+    FcTypeUnknown = -1,
     FcTypeVoid,
     FcTypeInteger,
     FcTypeDouble,
index fcdf73e..9c0be24 100644 (file)
@@ -721,7 +721,7 @@ FcConfigPromote (FcValue v, FcValue u, FcValuePromotionBuffer *buf)
 
 FcBool
 FcConfigCompareValue (const FcValue    *left_o,
-                     FcOp              op_,
+                     unsigned int      op_,
                      const FcValue     *right_o)
 {
     FcValue    left = FcValueCanonicalize(left_o);
@@ -736,6 +736,8 @@ FcConfigCompareValue (const FcValue *left_o,
     if (left.type == right.type)
     {
        switch (left.type) {
+       case FcTypeUnknown:
+           break;      /* No way to guess how to compare for this object */
        case FcTypeInteger:
            break;      /* FcConfigPromote prevents this from happening */
        case FcTypeDouble:
index 9d02f5a..ce64214 100644 (file)
@@ -30,6 +30,9 @@ static void
 _FcValuePrintFile (FILE *f, const FcValue v)
 {
     switch (v.type) {
+    case FcTypeUnknown:
+       fprintf (f, "<unknown>");
+       break;
     case FcTypeVoid:
        fprintf (f, "<void>");
        break;
@@ -98,6 +101,10 @@ FcValueBindingPrint (const FcValueListPtr l)
     case FcValueBindingSame:
        printf ("(=)");
        break;
+    default:
+       /* shouldn't be reached */
+       printf ("(?)");
+       break;
     }
 }
 
index 65bf333..0137dee 100644 (file)
@@ -107,7 +107,9 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
 FC_ASSERT_STATIC (sizeof (FcRef) == sizeof (int));
 
 typedef enum _FcValueBinding {
-    FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame
+    FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame,
+    /* to make sure sizeof (FcValueBinding) == 4 even with -fshort-enums */
+    FcValueBindingEnd = 0xffffffff
 } FcValueBinding;
 
 #define FcStrdup(s) ((FcChar8 *) strdup ((const char *) (s)))
@@ -623,7 +625,7 @@ FcConfigSetFonts (FcConfig  *config,
 
 FcPrivate FcBool
 FcConfigCompareValue (const FcValue *m,
-                     FcOp          op,
+                     unsigned int   op_,
                      const FcValue *v);
 
 FcPrivate FcBool
index b7ae899..c56e24c 100644 (file)
@@ -252,6 +252,7 @@ FcListValueHash (FcValue    *value)
 {
     FcValue v = FcValueCanonicalize(value);
     switch (v.type) {
+    case FcTypeUnknown:
     case FcTypeVoid:
        return 0;
     case FcTypeInteger:
index 8d02da7..712b2fa 100644 (file)
@@ -76,6 +76,8 @@ FcObjectValidType (FcObject object, FcType type)
 
     if (t) {
        switch ((int) t->type) {
+       case FcTypeUnknown:
+           return FcTrue;
        case FcTypeDouble:
        case FcTypeInteger:
            if (type == FcTypeDouble || type == FcTypeInteger)
@@ -86,7 +88,7 @@ FcObjectValidType (FcObject object, FcType type)
                return FcTrue;
            break;
        default:
-           if ((unsigned int) t->type == (unsigned int) -1 || type == t->type)
+           if (type == t->type)
                return FcTrue;
            break;
        }
@@ -474,6 +476,7 @@ FcNameUnparseValue (FcStrBuf        *buf,
     FcValue v = FcValueCanonicalize(v0);
 
     switch (v.type) {
+    case FcTypeUnknown:
     case FcTypeVoid:
        return FcTrue;
     case FcTypeInteger:
index 146ca70..1d3af73 100644 (file)
@@ -63,7 +63,7 @@ retry:
            return NULL;
 
        ot->object.object = (const char *) FcStrdup (str);
-       ot->object.type = -1;
+       ot->object.type = FcTypeUnknown;
        ot->id = fc_atomic_int_add (next_id, +1);
        ot->next = ots;
 
index 25bff64..0614ac2 100644 (file)
@@ -246,6 +246,8 @@ FcValueEqual (FcValue va, FcValue vb)
            return FcFalse;
     }
     switch (va.type) {
+    case FcTypeUnknown:
+       return FcFalse; /* don't know how to compare this object */
     case FcTypeVoid:
        return FcTrue;
     case FcTypeInteger:
@@ -294,6 +296,7 @@ static FcChar32
 FcValueHash (const FcValue *v)
 {
     switch (v->type) {
+    case FcTypeUnknown:
     case FcTypeVoid:
        return 0;
     case FcTypeInteger:
@@ -317,7 +320,7 @@ FcValueHash (const FcValue *v)
     case FcTypeLangSet:
        return FcLangSetHash (FcValueLangSet(v));
     }
-    return FcFalse;
+    return 0;
 }
 
 static FcBool
index 470e44f..7e03230 100644 (file)
@@ -705,7 +705,7 @@ FcTestCreate (FcConfigParse *parse,
              FcMatchKind   kind,
              FcQual        qual,
              const FcChar8 *field,
-             FcOp          compare,
+             unsigned int  compare,
              FcExpr        *expr)
 {
     FcTest     *test = (FcTest *) malloc (sizeof (FcTest));