xserver: Branch 'master'

Paulo Cesar Pereira de Andrade pcpa at kemper.freedesktop.org
Wed Jan 28 14:43:26 PST 2009


 xkb/xkbUtils.c |   39 +++++++++------------------------------
 1 file changed, 9 insertions(+), 30 deletions(-)

New commits:
commit 756a2c848305aa06bfe636314e28ad7f97c1168a
Author: Pierre Willenbrock <pierre at pirsoft.de>
Date:   Wed Jan 28 22:18:50 2009 +0100

    Fix duplicate code, off-by one in space calculation, not initialized members

diff --git a/xkb/xkbUtils.c b/xkb/xkbUtils.c
index 3cd3557..807c654 100644
--- a/xkb/xkbUtils.c
+++ b/xkb/xkbUtils.c
@@ -422,8 +422,10 @@ int			maxNumberOfGroups;
         maxSymsPerKey = maxNumberOfGroups * maxGroup1Width;
 
     syms->mapWidth = maxSymsPerKey;
+    syms->minKeyCode = xkb->min_key_code;
+    syms->maxKeyCode = xkb->max_key_code;
 
-    tmp = syms->mapWidth * (xkb->max_key_code - xkb->min_key_code);
+    tmp = syms->mapWidth * (xkb->max_key_code - xkb->min_key_code + 1);
     syms->map = xcalloc(tmp, sizeof(*syms->map));
     if (!syms->map) {
         xfree(syms);
@@ -455,7 +457,7 @@ int			maxNumberOfGroups;
 	 */
 	if (nGroups == 1)
 	{
-	    int idx;
+	    int idx, j;
 
 	    groupWidth = XkbKeyGroupWidth(xkb, key, XkbGroup1Index);
 
@@ -470,39 +472,16 @@ int			maxNumberOfGroups;
 	    while (groupWidth > 2 && idx < syms->mapWidth &&
 		   idx < groupWidth * 2)
 	    {
-		int idx, j;
-
-		groupWidth = XkbKeyGroupWidth(xkb, key, XkbGroup1Index);
-
-		/* AB..CDE... -> ABABCDE... */
-		if (groupWidth > 0 && maxSymsPerKey >= 3)
-		    pCore[2] = pCore[0];
-		if (groupWidth > 1 && maxSymsPerKey >= 4)
-		    pCore[3] = pCore[1];
-
-		/* ABABCDE... -> ABABCDECDE */
-		idx = 2 + groupWidth;
-		while (groupWidth > 2 &&
-			idx < maxSymsPerKey &&
-			idx < groupWidth * 2)
-		{
-		    pCore[idx] = pCore[idx - groupWidth + 2];
-		    idx++;
-		}
-		idx = 2 * groupWidth;
-		if (idx < 4)
-		    idx = 4;
-		/* 3 or more groups: ABABCDECDEABCDEABCDE */
-                for (j = 3; j <= maxNumberOfGroups; j++)
-                    for (n = 0; n < groupWidth && idx < maxSymsPerKey; n++)
-                        pCore[idx++] = pXKB[n];
+		pCore[idx] = pCore[idx - groupWidth + 2];
+		idx++;
 	    }
 	    idx = 2 * groupWidth;
 	    if (idx < 4)
 		idx = 4;
 	    /* 3 or more groups: ABABCDECDEABCDEABCDE */
-	    for (n = 0; n < groupWidth && idx < syms->mapWidth; n++)
-		pCore[idx++] = pXKB[n];
+	    for (j = 3; j <= maxNumberOfGroups; j++)
+		for (n = 0; n < groupWidth && idx < maxSymsPerKey; n++)
+		    pCore[idx++] = pXKB[n];
 	}
 
 	pXKB+= XkbKeyGroupsWidth(xkb,key);


More information about the xorg-commit mailing list