Add FcTypeUnknown to FcType to avoid comparison of constant -1

This change reverts 9acc14c34a
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
This commit is contained in:
Akira TAGOH 2013-06-28 15:04:11 +09:00
parent 38ab7ab2fb
commit 197d06c49b
10 changed files with 28 additions and 8 deletions

View File

@ -48,8 +48,9 @@
__o__ = va_arg (va, const char *); \ __o__ = va_arg (va, const char *); \
if (!__o__) \ if (!__o__) \
break; \ break; \
__v__.type = va_arg (va, FcType); \ __v__.type = va_arg (va, int); \
switch (__v__.type) { \ switch (__v__.type) { \
case FcTypeUnknown: \
case FcTypeVoid: \ case FcTypeVoid: \
goto _FcPatternVapBuild_bail1; \ goto _FcPatternVapBuild_bail1; \
case FcTypeInteger: \ case FcTypeInteger: \

View File

@ -185,6 +185,7 @@ typedef int FcBool;
#define FC_LCD_LEGACY 3 #define FC_LCD_LEGACY 3
typedef enum _FcType { typedef enum _FcType {
FcTypeUnknown = -1,
FcTypeVoid, FcTypeVoid,
FcTypeInteger, FcTypeInteger,
FcTypeDouble, FcTypeDouble,

View File

@ -721,7 +721,7 @@ FcConfigPromote (FcValue v, FcValue u, FcValuePromotionBuffer *buf)
FcBool FcBool
FcConfigCompareValue (const FcValue *left_o, FcConfigCompareValue (const FcValue *left_o,
FcOp op_, unsigned int op_,
const FcValue *right_o) const FcValue *right_o)
{ {
FcValue left = FcValueCanonicalize(left_o); FcValue left = FcValueCanonicalize(left_o);
@ -736,6 +736,8 @@ FcConfigCompareValue (const FcValue *left_o,
if (left.type == right.type) if (left.type == right.type)
{ {
switch (left.type) { switch (left.type) {
case FcTypeUnknown:
break; /* No way to guess how to compare for this object */
case FcTypeInteger: case FcTypeInteger:
break; /* FcConfigPromote prevents this from happening */ break; /* FcConfigPromote prevents this from happening */
case FcTypeDouble: case FcTypeDouble:

View File

@ -30,6 +30,9 @@ static void
_FcValuePrintFile (FILE *f, const FcValue v) _FcValuePrintFile (FILE *f, const FcValue v)
{ {
switch (v.type) { switch (v.type) {
case FcTypeUnknown:
fprintf (f, "<unknown>");
break;
case FcTypeVoid: case FcTypeVoid:
fprintf (f, "<void>"); fprintf (f, "<void>");
break; break;
@ -98,6 +101,10 @@ FcValueBindingPrint (const FcValueListPtr l)
case FcValueBindingSame: case FcValueBindingSame:
printf ("(=)"); printf ("(=)");
break; break;
default:
/* shouldn't be reached */
printf ("(?)");
break;
} }
} }

View File

@ -107,7 +107,9 @@ extern pfnSHGetFolderPathA pSHGetFolderPathA;
FC_ASSERT_STATIC (sizeof (FcRef) == sizeof (int)); FC_ASSERT_STATIC (sizeof (FcRef) == sizeof (int));
typedef enum _FcValueBinding { typedef enum _FcValueBinding {
FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame FcValueBindingWeak, FcValueBindingStrong, FcValueBindingSame,
/* to make sure sizeof (FcValueBinding) == 4 even with -fshort-enums */
FcValueBindingEnd = 0xffffffff
} FcValueBinding; } FcValueBinding;
#define FcStrdup(s) ((FcChar8 *) strdup ((const char *) (s))) #define FcStrdup(s) ((FcChar8 *) strdup ((const char *) (s)))
@ -623,7 +625,7 @@ FcConfigSetFonts (FcConfig *config,
FcPrivate FcBool FcPrivate FcBool
FcConfigCompareValue (const FcValue *m, FcConfigCompareValue (const FcValue *m,
FcOp op, unsigned int op_,
const FcValue *v); const FcValue *v);
FcPrivate FcBool FcPrivate FcBool

View File

@ -252,6 +252,7 @@ FcListValueHash (FcValue *value)
{ {
FcValue v = FcValueCanonicalize(value); FcValue v = FcValueCanonicalize(value);
switch (v.type) { switch (v.type) {
case FcTypeUnknown:
case FcTypeVoid: case FcTypeVoid:
return 0; return 0;
case FcTypeInteger: case FcTypeInteger:

View File

@ -76,6 +76,8 @@ FcObjectValidType (FcObject object, FcType type)
if (t) { if (t) {
switch ((int) t->type) { switch ((int) t->type) {
case FcTypeUnknown:
return FcTrue;
case FcTypeDouble: case FcTypeDouble:
case FcTypeInteger: case FcTypeInteger:
if (type == FcTypeDouble || type == FcTypeInteger) if (type == FcTypeDouble || type == FcTypeInteger)
@ -86,7 +88,7 @@ FcObjectValidType (FcObject object, FcType type)
return FcTrue; return FcTrue;
break; break;
default: default:
if ((unsigned int) t->type == (unsigned int) -1 || type == t->type) if (type == t->type)
return FcTrue; return FcTrue;
break; break;
} }
@ -474,6 +476,7 @@ FcNameUnparseValue (FcStrBuf *buf,
FcValue v = FcValueCanonicalize(v0); FcValue v = FcValueCanonicalize(v0);
switch (v.type) { switch (v.type) {
case FcTypeUnknown:
case FcTypeVoid: case FcTypeVoid:
return FcTrue; return FcTrue;
case FcTypeInteger: case FcTypeInteger:

View File

@ -63,7 +63,7 @@ retry:
return NULL; return NULL;
ot->object.object = (const char *) FcStrdup (str); 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->id = fc_atomic_int_add (next_id, +1);
ot->next = ots; ot->next = ots;

View File

@ -246,6 +246,8 @@ FcValueEqual (FcValue va, FcValue vb)
return FcFalse; return FcFalse;
} }
switch (va.type) { switch (va.type) {
case FcTypeUnknown:
return FcFalse; /* don't know how to compare this object */
case FcTypeVoid: case FcTypeVoid:
return FcTrue; return FcTrue;
case FcTypeInteger: case FcTypeInteger:
@ -294,6 +296,7 @@ static FcChar32
FcValueHash (const FcValue *v) FcValueHash (const FcValue *v)
{ {
switch (v->type) { switch (v->type) {
case FcTypeUnknown:
case FcTypeVoid: case FcTypeVoid:
return 0; return 0;
case FcTypeInteger: case FcTypeInteger:
@ -317,7 +320,7 @@ FcValueHash (const FcValue *v)
case FcTypeLangSet: case FcTypeLangSet:
return FcLangSetHash (FcValueLangSet(v)); return FcLangSetHash (FcValueLangSet(v));
} }
return FcFalse; return 0;
} }
static FcBool static FcBool

View File

@ -705,7 +705,7 @@ FcTestCreate (FcConfigParse *parse,
FcMatchKind kind, FcMatchKind kind,
FcQual qual, FcQual qual,
const FcChar8 *field, const FcChar8 *field,
FcOp compare, unsigned int compare,
FcExpr *expr) FcExpr *expr)
{ {
FcTest *test = (FcTest *) malloc (sizeof (FcTest)); FcTest *test = (FcTest *) malloc (sizeof (FcTest));