[Fontconfig] fontconfig: Branch 'master'

Akira TAGOH tagoh at kemper.freedesktop.org
Thu Mar 22 03:16:19 PDT 2012


 src/fcmatch.c |   19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

New commits:
commit 92ac054ce5e270f22a4f81a09522c3f03b76c876
Author: Akira TAGOH <akira at tagoh.org>
Date:   Thu Mar 22 19:15:27 2012 +0900

    fcmatch: Set FcResultMatch at the end if the return value is valid.
    
    In the previous code, the result of 'result' in the argument for
    FcFontSetSort() and FcFontSetMatch() wasn't predictable and not reliable to
    check if the return value is valid or not. this change is to ensure if it's
    performed successfully.

diff --git a/src/fcmatch.c b/src/fcmatch.c
index 422bc38..92e4a66 100644
--- a/src/fcmatch.c
+++ b/src/fcmatch.c
@@ -501,11 +501,11 @@ FcFontSetMatchInternal (FcConfig    *config,
 	printf ("\n");
 	FcPatternPrint (best);
     }
-    if (!best)
-    {
-	*result = FcResultNoMatch;
-	return 0;
-    }
+    /* assuming that 'result' is initialized with FcResultNoMatch
+     * outside this function */
+    if (best)
+	*result = FcResultMatch;
+
     return best;
 }
 
@@ -522,6 +522,8 @@ FcFontSetMatch (FcConfig    *config,
     assert (p != NULL);
     assert (result != NULL);
 
+    *result = FcResultNoMatch;
+
     if (!config)
     {
 	config = FcConfigGetCurrent ();
@@ -547,6 +549,8 @@ FcFontMatch (FcConfig	*config,
     assert (p != NULL);
     assert (result != NULL);
 
+    *result = FcResultNoMatch;
+
     if (!config)
     {
 	config = FcConfigGetCurrent ();
@@ -826,6 +830,9 @@ FcFontSetSort (FcConfig	    *config,
 	printf ("First font ");
 	FcPatternPrint (ret->fonts[0]);
     }
+    if (ret->nfont > 0)
+	*result = FcResultMatch;
+
     return ret;
 
 bail2:
@@ -849,6 +856,8 @@ FcFontSort (FcConfig	*config,
     assert (p != NULL);
     assert (result != NULL);
 
+    *result = FcResultNoMatch;
+
     if (!config)
     {
 	config = FcConfigGetCurrent ();


More information about the Fontconfig mailing list