mirror of
https://github.com/X11Libre/xserver.git
synced 2026-04-14 17:18:09 +00:00
xkb: XKBMisc: scoped declaration in loops and use int instead of register ints
Signed-off-by: sesankm <26676400+sesankm@users.noreply.github.com>
This commit is contained in:
@@ -49,14 +49,13 @@ XkbKeyTypesForCoreSymbols(XkbDescPtr xkb,
|
||||
unsigned int protected,
|
||||
int *types_inout, KeySym * xkb_syms_rtrn)
|
||||
{
|
||||
register int i;
|
||||
int nSyms[XkbNumKbdGroups];
|
||||
BOOL replicated = FALSE;
|
||||
|
||||
/* Section 12.2 of the protocol describes this process in more detail */
|
||||
/* Step 1: find the # of symbols in the core mapping per group */
|
||||
int groupsWidth = 2;
|
||||
for (i = 0; i < XkbNumKbdGroups; i++) {
|
||||
for (int i = 0; i < XkbNumKbdGroups; i++) {
|
||||
if ((protected & (1 << i)) && (types_inout[i] < xkb->map->num_types)) {
|
||||
nSyms[i] = xkb->map->types[types_inout[i]].num_levels;
|
||||
if (nSyms[i] > groupsWidth)
|
||||
@@ -76,21 +75,20 @@ XkbKeyTypesForCoreSymbols(XkbDescPtr xkb,
|
||||
/* G1L1 G1L2 G2L1 G2L2 [G1L[3-n]] [G2L[3-n]] [G3L*] [G3L*] */
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index, 0)] = CORE_SYM(0);
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index, 1)] = CORE_SYM(1);
|
||||
for (i = 2; i < nSyms[XkbGroup1Index]; i++) {
|
||||
for (int i = 2; i < nSyms[XkbGroup1Index]; i++) {
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index, i)] = CORE_SYM(2 + i);
|
||||
}
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index, 0)] = CORE_SYM(2);
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index, 1)] = CORE_SYM(3);
|
||||
int tmp = 2 + (nSyms[XkbGroup1Index] - 2); /* offset to extra group2 syms */
|
||||
for (i = 2; i < nSyms[XkbGroup2Index]; i++) {
|
||||
for (int i = 2; i < nSyms[XkbGroup2Index]; i++) {
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index, i)] = CORE_SYM(tmp + i);
|
||||
}
|
||||
|
||||
/* Special case: if only the first group is explicit, and the symbols
|
||||
* replicate across all groups, then we have a Section 12.4 replication */
|
||||
if ((protected & ~XkbExplicitKeyType1Mask) == 0) {
|
||||
int j, width = nSyms[XkbGroup1Index];
|
||||
|
||||
int width = nSyms[XkbGroup1Index];
|
||||
replicated = TRUE;
|
||||
|
||||
/* Check ABAB in ABABCDECDEABCDE */
|
||||
@@ -99,15 +97,15 @@ XkbKeyTypesForCoreSymbols(XkbDescPtr xkb,
|
||||
replicated = FALSE;
|
||||
|
||||
/* Check CDECDE in ABABCDECDEABCDE */
|
||||
for (i = 2; i < width && replicated; i++) {
|
||||
for (int i = 2; i < width && replicated; i++) {
|
||||
if (CORE_SYM(2 + i) != CORE_SYM(i + width))
|
||||
replicated = FALSE;
|
||||
}
|
||||
|
||||
/* Check ABCDE in ABABCDECDEABCDE */
|
||||
for (j = 2; replicated &&
|
||||
for (int j = 2; replicated &&
|
||||
j < XkbNumKbdGroups && map_width >= width * (j + 1); j++) {
|
||||
for (i = 0; i < width && replicated; i++) {
|
||||
for (int i = 0; i < width && replicated; i++) {
|
||||
if (CORE_SYM(((i < 2) ? i : 2 + i)) != CORE_SYM(i + width * j))
|
||||
replicated = FALSE;
|
||||
}
|
||||
@@ -132,12 +130,12 @@ XkbKeyTypesForCoreSymbols(XkbDescPtr xkb,
|
||||
}
|
||||
else {
|
||||
nGroups = 3;
|
||||
for (i = 0; i < nSyms[XkbGroup3Index]; i++, tmp++) {
|
||||
for (int i = 0; i < nSyms[XkbGroup3Index]; i++, tmp++) {
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup3Index, i)] = CORE_SYM(tmp);
|
||||
}
|
||||
if ((tmp < map_width) || (protected & XkbExplicitKeyType4Mask)) {
|
||||
nGroups = 4;
|
||||
for (i = 0; i < nSyms[XkbGroup4Index]; i++, tmp++) {
|
||||
for (int i = 0; i < nSyms[XkbGroup4Index]; i++, tmp++) {
|
||||
xkb_syms_rtrn[XKB_OFFSET(XkbGroup4Index, i)] =
|
||||
CORE_SYM(tmp);
|
||||
}
|
||||
@@ -149,7 +147,7 @@ XkbKeyTypesForCoreSymbols(XkbDescPtr xkb,
|
||||
}
|
||||
/* steps 3&4: alphanumeric expansion, assign canonical types */
|
||||
unsigned int empty = 0;
|
||||
for (i = 0; i < nGroups; i++) {
|
||||
for (int i = 0; i < nGroups; i++) {
|
||||
KeySym *syms = &xkb_syms_rtrn[XKB_OFFSET(i, 0)];
|
||||
|
||||
if ((nSyms[i] > 1) && (syms[1] == NoSymbol) && (syms[0] != NoSymbol)) {
|
||||
@@ -180,10 +178,9 @@ XkbKeyTypesForCoreSymbols(XkbDescPtr xkb,
|
||||
}
|
||||
}
|
||||
if (syms[0] == NoSymbol) {
|
||||
register int n;
|
||||
Bool found = FALSE;
|
||||
|
||||
for (n = 1; (!found) && (n < nSyms[i]); n++) {
|
||||
for (int n = 1; (!found) && (n < nSyms[i]); n++) {
|
||||
found = (syms[n] != NoSymbol);
|
||||
}
|
||||
if (!found)
|
||||
@@ -192,7 +189,7 @@ XkbKeyTypesForCoreSymbols(XkbDescPtr xkb,
|
||||
}
|
||||
/* step 5: squoosh out empty groups */
|
||||
if (empty) {
|
||||
for (i = nGroups - 1; i >= 0; i--) {
|
||||
for (int i = nGroups - 1; i >= 0; i--) {
|
||||
if (((empty & (1 << i)) == 0) || (protected & (1 << i)))
|
||||
break;
|
||||
nGroups--;
|
||||
@@ -229,7 +226,7 @@ XkbKeyTypesForCoreSymbols(XkbDescPtr xkb,
|
||||
canonical = TRUE,
|
||||
allOneLevel = (xkb->map->types[types_inout[0]].num_levels == 1);
|
||||
|
||||
for (i = 1; (allOneLevel || sameType) && (i < nGroups); i++) {
|
||||
for (int i = 1; (allOneLevel || sameType) && (i < nGroups); i++) {
|
||||
sameType = (sameType &&
|
||||
(types_inout[i] == types_inout[XkbGroup1Index]));
|
||||
if (allOneLevel)
|
||||
@@ -240,16 +237,15 @@ XkbKeyTypesForCoreSymbols(XkbDescPtr xkb,
|
||||
if (((sameType) || canonical) &&
|
||||
(!(protected &
|
||||
(XkbExplicitKeyTypesMask & ~XkbExplicitKeyType1Mask)))) {
|
||||
register int s;
|
||||
Bool identical = TRUE;
|
||||
|
||||
for (i = 1; identical && (i < nGroups); i++) {
|
||||
for (int i = 1; identical && (i < nGroups); i++) {
|
||||
KeySym *syms;
|
||||
|
||||
if (nSyms[i] != nSyms[XkbGroup1Index])
|
||||
identical = FALSE;
|
||||
syms = &xkb_syms_rtrn[XKB_OFFSET(i, 0)];
|
||||
for (s = 0; identical && (s < nSyms[i]); s++) {
|
||||
for (int s = 0; identical && (s < nSyms[i]); s++) {
|
||||
if (syms[s] != xkb_syms_rtrn[s])
|
||||
identical = FALSE;
|
||||
}
|
||||
@@ -260,7 +256,7 @@ XkbKeyTypesForCoreSymbols(XkbDescPtr xkb,
|
||||
if (allOneLevel && (nGroups > 1)) {
|
||||
KeySym *syms = &xkb_syms_rtrn[nSyms[XkbGroup1Index]];
|
||||
nSyms[XkbGroup1Index] = 1;
|
||||
for (i = 1; i < nGroups; i++) {
|
||||
for (int i = 1; i < nGroups; i++) {
|
||||
xkb_syms_rtrn[i] = syms[0];
|
||||
syms += nSyms[i];
|
||||
nSyms[i] = 1;
|
||||
|
||||
Reference in New Issue
Block a user