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

Hong Xu hong at topbug.net
Wed Mar 18 23:28:49 PDT 2015


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

The strcpy line and get_font_name line in the loop are also removed
since they are unneeded.

Signed-off-by: Hong Xu <hong at topbug.net>
---
 modules/om/generic/omGeneric.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/modules/om/generic/omGeneric.c b/modules/om/generic/omGeneric.c
index a835f00d7989..3ccb5448c82f 100644
--- a/modules/om/generic/omGeneric.c
+++ b/modules/om/generic/omGeneric.c
@@ -808,6 +808,18 @@ 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;
+    }
+
    /* 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 +831,6 @@ parse_omit_name(
     * we've found a match.
     */
 
-    last++;
-
     if ((last - buf) + strlen(font_data->name) > XLFD_MAX_LEN)
 	return -1;
 
@@ -828,20 +838,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