[PATCH] parse_omit_name should increase num of fields before appending encoding

Hong Xu hong at topbug.net
Sun Mar 15 23:03:13 PDT 2015


parse_omit_name currently does not increase number of fields to 12 after
appending encoding, This does not lead to the correct font is a xlfd
like "-*-*-medium-r-*-*-33-*" is given.

Signed-off-by: Hong Xu <hong at topbug.net>

---
Please note that the "if" in this patch is replaced by "while". The
reason is that I found the commit 3d69b0a83e62f8f6fbd changed the
"while" to "if", which does not seems logically correct for me and
actually accidently "fixed" the bug
http://sourceware.org/bugzilla/show_bug.cgi?id=10948
---
 modules/om/generic/omGeneric.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)

diff --git a/modules/om/generic/omGeneric.c b/modules/om/generic/omGeneric.c
index a835f00d7989..f447eb30ef78 100644
--- a/modules/om/generic/omGeneric.c
+++ b/modules/om/generic/omGeneric.c
@@ -808,6 +808,20 @@ parse_omit_name(
 	break;
     }
 
+    last++;
+
+    /* This may mot be needed anymore as XListFonts() takes care of this */
+    while (num_fields < 12) {
+	if ((last - buf) > (XLFD_MAX_LEN - 2))
+	    return -1;
+	*last = '*';
+	*(last + 1) = '-';
+	num_fields++;
+	last+=2;
+	if ((font_data->xlfd_name = get_font_name(oc, buf)) != NULL)
+	    return True;
+    }
+
    /* At this point, "last" is pointing to the last "-" in the
     * xlfd, and all xlfd's at this point take a form similar to:
     *       -*-*-*-*-*-*-14-*-*-*-*-*-
@@ -819,8 +833,6 @@ parse_omit_name(
     * we've found a match.
     */
 
-    last++;
-
     if ((last - buf) + strlen(font_data->name) > XLFD_MAX_LEN)
 	return -1;
 
@@ -828,20 +840,6 @@ parse_omit_name(
     if ((font_data->xlfd_name = get_font_name(oc, buf)) != NULL)
 	return True;
 
-    /* This may mot be needed anymore as XListFonts() takes care of this */
-    if (num_fields < 12) {
-	if ((last - buf) > (XLFD_MAX_LEN - 2))
-	    return -1;
-	*last = '*';
-	*(last + 1) = '-';
-	strcpy(last + 2, font_data->name);
-	num_fields++;
-	last+=2;
-	if ((font_data->xlfd_name = get_font_name(oc, buf)) != NULL)
-	    return True;
-    }
-
-
     return False;
 }
 
-- 
2.3.3




More information about the xorg-devel mailing list