[Fontconfig] fontconfig: Branch 'master'

Akira TAGOH tagoh at kemper.freedesktop.org
Thu Jun 27 23:05:56 PDT 2013


 fontconfig/fcprivate.h  |    3 ++-
 fontconfig/fontconfig.h |    1 +
 src/fccfg.c             |    4 +++-
 src/fcdbg.c             |    7 +++++++
 src/fcint.h             |    6 ++++--
 src/fclist.c            |    1 +
 src/fcname.c            |    5 ++++-
 src/fcobjs.c            |    2 +-
 src/fcpat.c             |    5 ++++-
 src/fcxml.c             |    2 +-
 10 files changed, 28 insertions(+), 8 deletions(-)

New commits:
commit 197d06c49b01413303f2c92130594daa4fcaa6ad
Author: Akira TAGOH <akira at tagoh.org>
Date:   Fri Jun 28 15:04:11 2013 +0900

    Add FcTypeUnknown to FcType to avoid comparison of constant -1
    
    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

diff --git a/fontconfig/fcprivate.h b/fontconfig/fcprivate.h
index 18b8c08..210c1d8 100644
--- a/fontconfig/fcprivate.h
+++ b/fontconfig/fcprivate.h
@@ -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:	    				    \
diff --git a/fontconfig/fontconfig.h b/fontconfig/fontconfig.h
index 422187b..39d1b1b 100644
--- a/fontconfig/fontconfig.h
+++ b/fontconfig/fontconfig.h
@@ -185,6 +185,7 @@ typedef int		FcBool;
 #define FC_LCD_LEGACY	    3
 
 typedef enum _FcType {
+    FcTypeUnknown = -1,
     FcTypeVoid,
     FcTypeInteger,
     FcTypeDouble,
diff --git a/src/fccfg.c b/src/fccfg.c
index fcdf73e..9c0be24 100644
--- a/src/fccfg.c
+++ b/src/fccfg.c
@@ -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:
diff --git a/src/fcdbg.c b/src/fcdbg.c
index 9d02f5a..ce64214 100644
--- a/src/fcdbg.c
+++ b/src/fcdbg.c
@@ -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;
     }
 }
 
diff --git a/src/fcint.h b/src/fcint.h
index 65bf333..0137dee 100644
--- a/src/fcint.h
+++ b/src/fcint.h
@@ -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
diff --git a/src/fclist.c b/src/fclist.c
index b7ae899..c56e24c 100644
--- a/src/fclist.c
+++ b/src/fclist.c
@@ -252,6 +252,7 @@ FcListValueHash (FcValue    *value)
 {
     FcValue v = FcValueCanonicalize(value);
     switch (v.type) {
+    case FcTypeUnknown:
     case FcTypeVoid:
 	return 0;
     case FcTypeInteger:
diff --git a/src/fcname.c b/src/fcname.c
index 8d02da7..712b2fa 100644
--- a/src/fcname.c
+++ b/src/fcname.c
@@ -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:
diff --git a/src/fcobjs.c b/src/fcobjs.c
index 146ca70..1d3af73 100644
--- a/src/fcobjs.c
+++ b/src/fcobjs.c
@@ -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;
 
diff --git a/src/fcpat.c b/src/fcpat.c
index 25bff64..0614ac2 100644
--- a/src/fcpat.c
+++ b/src/fcpat.c
@@ -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
diff --git a/src/fcxml.c b/src/fcxml.c
index 470e44f..7e03230 100644
--- a/src/fcxml.c
+++ b/src/fcxml.c
@@ -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));


More information about the Fontconfig mailing list