xserver: Branch 'master' - 17 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Feb 26 13:54:13 UTC 2025


 include/xkbrules.h  |   73 ------------------------------
 xkb/ddxLoad.c       |    5 +-
 xkb/maprules.c      |  124 ++++++++++++++++++----------------------------------
 xkb/xkbInit.c       |    2 
 xkb/xkbrules_priv.h |   61 +++++++++++++++++++++++++
 5 files changed, 109 insertions(+), 156 deletions(-)

New commits:
commit a0c1eeea98b907abc0fd1200f2be6308c854d5c6
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 12:09:20 2025 +0100

    xkb: simplify loops in XkbRF_Free()
    
    Make the code a bit easier to read by simplifying the loops.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/xkb/maprules.c b/xkb/maprules.c
index 222b6107e..8a1944ef5 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -971,31 +971,34 @@ XkbRF_LoadRules(FILE * file, XkbRF_RulesPtr rules)
 void
 XkbRF_Free(XkbRF_RulesPtr rules)
 {
-    int i;
-    XkbRF_RulePtr rule;
-    XkbRF_GroupPtr group;
-
     if (!rules)
         return;
+
     if (rules->rules) {
-        for (i = 0, rule = rules->rules; i < rules->num_rules; i++, rule++) {
-            free((void *) rule->model);
-            free((void *) rule->layout);
-            free((void *) rule->variant);
-            free((void *) rule->option);
-            free((void *) rule->keycodes);
-            free((void *) rule->symbols);
-            free((void *) rule->types);
-            free((void *) rule->compat);
-            free((void *) rule->geometry);
+        XkbRF_RulePtr r = rules->rules;
+        int num = rules->num_rules;
+        for (int i = 0; i < num; i++) {
+            // the typecast on free() is necessary because the pointers are const
+            free((void *) r[i].model);
+            free((void *) r[i].layout);
+            free((void *) r[i].variant);
+            free((void *) r[i].option);
+            free((void *) r[i].keycodes);
+            free((void *) r[i].symbols);
+            free((void *) r[i].types);
+            free((void *) r[i].compat);
+            free((void *) r[i].geometry);
         }
         free(rules->rules);
     }
 
     if (rules->groups) {
-        for (i = 0, group = rules->groups; i < rules->num_groups; i++, group++) {
-            free((void *) group->name);
-            free(group->words);
+        XkbRF_GroupPtr g = rules->groups;
+        int num = rules->num_groups;
+        for (int i = 0; i < num; i++) {
+            // the typecast on free() is necessary because the pointers are const
+            free((void *) g[i].name);
+            free(g[i].words);
         }
         free(rules->groups);
     }
commit abfbc768240f740192e00e3c136d37f93bec542d
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 12:05:10 2025 +0100

    xkb: drop obsolete parameter from XkbRF_Free()
    
    The freeRules parameter is always set to TRUE, meaning always free the
    XkbRF_RulesRec struct. Therefore also no need to clear out fields that
    aren't going to be reused again, ever.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index 8001cb25d..a231e96bf 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -436,14 +436,14 @@ XkbDDXNamesFromRules(DeviceIntPtr keybd,
     if (!XkbRF_LoadRules(file, rules)) {
         LogMessage(X_ERROR, "XKB: Couldn't parse rules file %s\n", rules_name);
         fclose(file);
-        XkbRF_Free(rules, TRUE);
+        XkbRF_Free(rules);
         return FALSE;
     }
 
     memset(names, 0, sizeof(*names));
     complete = XkbRF_GetComponents(rules, defs, names);
     fclose(file);
-    XkbRF_Free(rules, TRUE);
+    XkbRF_Free(rules);
 
     if (!complete)
         LogMessage(X_ERROR, "XKB: Rules returned no components\n");
diff --git a/xkb/maprules.c b/xkb/maprules.c
index b5bdfefc3..222b6107e 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -969,7 +969,7 @@ XkbRF_LoadRules(FILE * file, XkbRF_RulesPtr rules)
 }
 
 void
-XkbRF_Free(XkbRF_RulesPtr rules, Bool freeRules)
+XkbRF_Free(XkbRF_RulesPtr rules)
 {
     int i;
     XkbRF_RulePtr rule;
@@ -988,11 +988,8 @@ XkbRF_Free(XkbRF_RulesPtr rules, Bool freeRules)
             free((void *) rule->types);
             free((void *) rule->compat);
             free((void *) rule->geometry);
-            memset((char *) rule, 0, sizeof(XkbRF_RuleRec));
         }
         free(rules->rules);
-        rules->num_rules = rules->sz_rules = 0;
-        rules->rules = NULL;
     }
 
     if (rules->groups) {
@@ -1001,10 +998,8 @@ XkbRF_Free(XkbRF_RulesPtr rules, Bool freeRules)
             free(group->words);
         }
         free(rules->groups);
-        rules->num_groups = 0;
-        rules->groups = NULL;
     }
-    if (freeRules)
-        free(rules);
+
+    free(rules);
     return;
 }
diff --git a/xkb/xkbrules_priv.h b/xkb/xkbrules_priv.h
index 3739c15a8..deb29d093 100644
--- a/xkb/xkbrules_priv.h
+++ b/xkb/xkbrules_priv.h
@@ -56,6 +56,6 @@ static inline XkbRF_RulesPtr XkbRF_Create(void)
     return calloc(1, sizeof(XkbRF_RulesRec));
 }
 
-void XkbRF_Free(XkbRF_RulesPtr rules, Bool freeRules);
+void XkbRF_Free(XkbRF_RulesPtr rules);
 
 #endif /* _XSERVER_XKB_XKBRULES_PRIV_H */
commit a88b17565bd98f2a5112e7e05ed1507c15c996f0
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 11:43:20 2025 +0100

    xkb: maprules: use static struct init instead of memset()
    
    Allow the compiler to figure out the most efficient way to do the
    struct initialization, and a little improvement on code readability.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/xkb/maprules.c b/xkb/maprules.c
index fe064fd14..b5bdfefc3 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -376,7 +376,6 @@ CheckLine(InputLine * line,
 {
     char *str, *tok;
     register int nread;
-    FileSpec tmp;
     _Xstrtokparams strtok_buf;
     Bool append = FALSE;
 
@@ -419,7 +418,9 @@ CheckLine(InputLine * line,
         DebugF("Illegal line of data ignored\n");
         return FALSE;
     }
-    memset((char *) &tmp, 0, sizeof(FileSpec));
+
+    FileSpec tmp = { 0 };
+
     str = line->line;
     for (nread = 0; (tok = _XStrtok(str, " ", strtok_buf)) != NULL; nread++) {
         str = NULL;
commit ffd7ca8af2885da59c9879abe8a15d698e73aa4a
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 11:40:36 2025 +0100

    xkb: maprules: put some loop counters into local scope
    
    Prevent from being accidentially removed and making the code a
    little bit easier to understand.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/xkb/maprules.c b/xkb/maprules.c
index 9c6f7c2b3..fe064fd14 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -262,7 +262,6 @@ SetUpRemap(InputLine * line, RemapSpec * remap)
 {
     char *tok, *str;
     unsigned present, l_ndx_present, v_ndx_present;
-    register int i;
     int len, ndx;
     _Xstrtokparams strtok_buf;
     Bool found;
@@ -277,7 +276,7 @@ SetUpRemap(InputLine * line, RemapSpec * remap)
         str = NULL;
         if (strcmp(tok, "=") == 0)
             continue;
-        for (i = 0; i < MAX_WORDS; i++) {
+        for (int i = 0; i < MAX_WORDS; i++) {
             len = strlen(cname[i]);
             if (strncmp(cname[i], tok, len) == 0) {
                 if (strlen(tok) > len) {
@@ -323,7 +322,7 @@ SetUpRemap(InputLine * line, RemapSpec * remap)
         unsigned mask = PART_MASK;
 
         ErrorF("Mapping needs at least one of ");
-        for (i = 0; (i < MAX_WORDS); i++) {
+        for (int i = 0; (i < MAX_WORDS); i++) {
             if ((1L << i) & mask) {
                 mask &= ~(1L << i);
                 if (mask)
@@ -376,7 +375,7 @@ CheckLine(InputLine * line,
           RemapSpec * remap, XkbRF_RulePtr rule, XkbRF_GroupPtr group)
 {
     char *str, *tok;
-    register int nread, i;
+    register int nread;
     FileSpec tmp;
     _Xstrtokparams strtok_buf;
     Bool append = FALSE;
@@ -398,6 +397,8 @@ CheckLine(InputLine * line,
                 return FALSE;
             group->name = Xstrdup(gname);
             group->words = Xstrdup(words);
+
+            int i;
             for (i = 1, words = group->words; *words; words++) {
                 if (*words == ' ') {
                     *words++ = '\0';
@@ -461,7 +462,7 @@ CheckLine(InputLine * line,
     rule->geometry = Xstrdup(tmp.name[GEOMETRY]);
 
     rule->layout_num = rule->variant_num = 0;
-    for (i = 0; i < nread; i++) {
+    for (int i = 0; i < nread; i++) {
         if (remap->remap[i].index) {
             if (remap->remap[i].word == LAYOUT)
                 rule->layout_num = remap->remap[i].index;
@@ -489,9 +490,7 @@ _Concat(char *str1, const char *str2)
 static void
 squeeze_spaces(char *p1)
 {
-    char *p2;
-
-    for (p2 = p1; *p2; p2++) {
+    for (char *p2 = p1; *p2; p2++) {
         *p1 = *p2;
         if (*p1 != ' ')
             p1++;
@@ -517,7 +516,6 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
         else {
             char *p;
             char *layout;
-            int i;
 
             layout = Xstrdup(defs->layout);
             if (layout == NULL)
@@ -525,7 +523,7 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
             squeeze_spaces(layout);
             mdefs->layout[1] = layout;
             p = layout;
-            for (i = 2; i <= XkbNumKbdGroups; i++) {
+            for (int i = 2; i <= XkbNumKbdGroups; i++) {
                 if ((p = strchr(p, ','))) {
                     *p++ = '\0';
                     mdefs->layout[i] = p;
@@ -546,7 +544,6 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
         else {
             char *p;
             char *variant;
-            int i;
 
             variant = Xstrdup(defs->variant);
             if (variant == NULL)
@@ -554,7 +551,7 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
             squeeze_spaces(variant);
             mdefs->variant[1] = variant;
             p = variant;
-            for (i = 2; i <= XkbNumKbdGroups; i++) {
+            for (int i = 2; i <= XkbNumKbdGroups; i++) {
                 if ((p = strchr(p, ','))) {
                     *p++ = '\0';
                     mdefs->variant[i] = p;
commit 60d37d0158ad9e1c29e4740e73911083e218c332
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 11:21:29 2025 +0100

    xkb: make XkbRF_Create() static inline
    
    The function is nothing more than a calloc() call, so we can spare
    an actual function call here by making it static inline.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/xkb/maprules.c b/xkb/maprules.c
index 83abe8076..9c6f7c2b3 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -970,16 +970,6 @@ XkbRF_LoadRules(FILE * file, XkbRF_RulesPtr rules)
     return TRUE;
 }
 
-/***====================================================================***/
-
-XkbRF_RulesPtr
-XkbRF_Create(void)
-{
-    return calloc(1, sizeof(XkbRF_RulesRec));
-}
-
-/***====================================================================***/
-
 void
 XkbRF_Free(XkbRF_RulesPtr rules, Bool freeRules)
 {
diff --git a/xkb/xkbrules_priv.h b/xkb/xkbrules_priv.h
index b494edb8d..3739c15a8 100644
--- a/xkb/xkbrules_priv.h
+++ b/xkb/xkbrules_priv.h
@@ -6,6 +6,7 @@
 #define _XSERVER_XKB_XKBRULES_PRIV_H
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <X11/Xdefs.h>
 
 #include "include/xkbrules.h"
@@ -50,7 +51,10 @@ Bool XkbRF_GetComponents(XkbRF_RulesPtr rules,
 
 Bool XkbRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
 
-XkbRF_RulesPtr XkbRF_Create(void);
+static inline XkbRF_RulesPtr XkbRF_Create(void)
+{
+    return calloc(1, sizeof(XkbRF_RulesRec));
+}
 
 void XkbRF_Free(XkbRF_RulesPtr rules, Bool freeRules);
 
commit a82fa008359022ed1beb05d403d3f1dbe933b2ff
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 10:49:06 2025 +0100

    xkb: unexport XkbRF_RuleRec struct
    
    Not used outside xkb, so no need to keep it in public API header.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/include/xkbrules.h b/include/xkbrules.h
index 2add6996e..20ea78e17 100644
--- a/include/xkbrules.h
+++ b/include/xkbrules.h
@@ -44,21 +44,4 @@ typedef struct _XkbRF_VarDefs {
     const char *options;
 } XkbRF_VarDefsRec, *XkbRF_VarDefsPtr;
 
-typedef struct _XkbRF_Rule {
-    int number;
-    int layout_num;
-    int variant_num;
-    const char *model;
-    const char *layout;
-    const char *variant;
-    const char *option;
-    /* yields */
-    const char *keycodes;
-    const char *symbols;
-    const char *types;
-    const char *compat;
-    const char *geometry;
-    unsigned flags;
-} XkbRF_RuleRec, *XkbRF_RulePtr;
-
 #endif                          /* _XKBRULES_H_ */
diff --git a/xkb/xkbrules_priv.h b/xkb/xkbrules_priv.h
index 918be5339..b494edb8d 100644
--- a/xkb/xkbrules_priv.h
+++ b/xkb/xkbrules_priv.h
@@ -10,6 +10,23 @@
 
 #include "include/xkbrules.h"
 
+typedef struct _XkbRF_Rule {
+    int number;
+    int layout_num;
+    int variant_num;
+    const char *model;
+    const char *layout;
+    const char *variant;
+    const char *option;
+    /* yields */
+    const char *keycodes;
+    const char *symbols;
+    const char *types;
+    const char *compat;
+    const char *geometry;
+    unsigned flags;
+} XkbRF_RuleRec, *XkbRF_RulePtr;
+
 typedef struct _XkbRF_Group {
     int number;
     const char *name;
commit 83c8a90a61a2dbeb755752ac66e16506be9aba34
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 10:45:27 2025 +0100

    xkb: unexport XkbRF_GroupRec struct
    
    Not used outside xkb, so no need to keep it in public API header.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/include/xkbrules.h b/include/xkbrules.h
index 98068afac..2add6996e 100644
--- a/include/xkbrules.h
+++ b/include/xkbrules.h
@@ -61,10 +61,4 @@ typedef struct _XkbRF_Rule {
     unsigned flags;
 } XkbRF_RuleRec, *XkbRF_RulePtr;
 
-typedef struct _XkbRF_Group {
-    int number;
-    const char *name;
-    char *words;
-} XkbRF_GroupRec, *XkbRF_GroupPtr;
-
 #endif                          /* _XKBRULES_H_ */
diff --git a/xkb/xkbrules_priv.h b/xkb/xkbrules_priv.h
index 71b1a8cd0..918be5339 100644
--- a/xkb/xkbrules_priv.h
+++ b/xkb/xkbrules_priv.h
@@ -10,6 +10,12 @@
 
 #include "include/xkbrules.h"
 
+typedef struct _XkbRF_Group {
+    int number;
+    const char *name;
+    char *words;
+} XkbRF_GroupRec, *XkbRF_GroupPtr;
+
 typedef struct _XkbRF_Rules {
     unsigned short sz_rules;
     unsigned short num_rules;
commit 043dc8041c09c444fe04b0322518205bd668b31c
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 10:43:03 2025 +0100

    xkb: unexport XkbRF_RulesRec struct
    
    Not used by any drivers, so no need to keep it in public header.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/include/xkbrules.h b/include/xkbrules.h
index b2c1c7230..98068afac 100644
--- a/include/xkbrules.h
+++ b/include/xkbrules.h
@@ -67,13 +67,4 @@ typedef struct _XkbRF_Group {
     char *words;
 } XkbRF_GroupRec, *XkbRF_GroupPtr;
 
-typedef struct _XkbRF_Rules {
-    unsigned short sz_rules;
-    unsigned short num_rules;
-    XkbRF_RulePtr rules;
-    unsigned short sz_groups;
-    unsigned short num_groups;
-    XkbRF_GroupPtr groups;
-} XkbRF_RulesRec, *XkbRF_RulesPtr;
-
 #endif                          /* _XKBRULES_H_ */
diff --git a/xkb/xkbrules_priv.h b/xkb/xkbrules_priv.h
index 8f1688030..71b1a8cd0 100644
--- a/xkb/xkbrules_priv.h
+++ b/xkb/xkbrules_priv.h
@@ -10,6 +10,15 @@
 
 #include "include/xkbrules.h"
 
+typedef struct _XkbRF_Rules {
+    unsigned short sz_rules;
+    unsigned short num_rules;
+    XkbRF_RulePtr rules;
+    unsigned short sz_groups;
+    unsigned short num_groups;
+    XkbRF_GroupPtr groups;
+} XkbRF_RulesRec, *XkbRF_RulesPtr;
+
 struct _XkbComponentNames;
 
 Bool XkbRF_GetComponents(XkbRF_RulesPtr rules,
commit 34372cb3da14f6086614ca4d8c9c5294c7b793bf
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 10:33:16 2025 +0100

    xkb: unexport XkbRF_Free()
    
    Only used inside xkb/* - not used by any modules, so no need
    to keep maintaining it in public headers.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/include/xkbrules.h b/include/xkbrules.h
index ac9de2bfd..b2c1c7230 100644
--- a/include/xkbrules.h
+++ b/include/xkbrules.h
@@ -76,13 +76,4 @@ typedef struct _XkbRF_Rules {
     XkbRF_GroupPtr groups;
 } XkbRF_RulesRec, *XkbRF_RulesPtr;
 
-/***====================================================================***/
-
-_XFUNCPROTOBEGIN
-
-extern _X_EXPORT void XkbRF_Free(XkbRF_RulesPtr /* rules */ ,
-                                 Bool   /* freeRules */
-    );
-
-_XFUNCPROTOEND
 #endif                          /* _XKBRULES_H_ */
diff --git a/xkb/xkbrules_priv.h b/xkb/xkbrules_priv.h
index 932ce3f1d..8f1688030 100644
--- a/xkb/xkbrules_priv.h
+++ b/xkb/xkbrules_priv.h
@@ -20,4 +20,6 @@ Bool XkbRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
 
 XkbRF_RulesPtr XkbRF_Create(void);
 
+void XkbRF_Free(XkbRF_RulesPtr rules, Bool freeRules);
+
 #endif /* _XSERVER_XKB_XKBRULES_PRIV_H */
commit 89475cbed488b46278ca46812d6443eba9d33797
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 10:31:11 2025 +0100

    xkb: unexport XkbRF_Create()
    
    Only used inside xkb/* - not used by any modules, so no need
    to keep maintaining it in public headers.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/include/xkbrules.h b/include/xkbrules.h
index 11bd6ab93..ac9de2bfd 100644
--- a/include/xkbrules.h
+++ b/include/xkbrules.h
@@ -80,8 +80,6 @@ typedef struct _XkbRF_Rules {
 
 _XFUNCPROTOBEGIN
 
-extern _X_EXPORT XkbRF_RulesPtr XkbRF_Create(void);
-
 extern _X_EXPORT void XkbRF_Free(XkbRF_RulesPtr /* rules */ ,
                                  Bool   /* freeRules */
     );
diff --git a/xkb/xkbrules_priv.h b/xkb/xkbrules_priv.h
index e498f6ced..932ce3f1d 100644
--- a/xkb/xkbrules_priv.h
+++ b/xkb/xkbrules_priv.h
@@ -18,4 +18,6 @@ Bool XkbRF_GetComponents(XkbRF_RulesPtr rules,
 
 Bool XkbRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
 
+XkbRF_RulesPtr XkbRF_Create(void);
+
 #endif /* _XSERVER_XKB_XKBRULES_PRIV_H */
commit c376cd2c3dfc82b842e0db8abdddd6fa0e455cdb
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 10:17:15 2025 +0100

    xkb: unexport XkbRF_LoadRules()
    
    Only used inside xkb/* - not used by any modules, so no need
    to keep maintaining it in public headers.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/include/xkbrules.h b/include/xkbrules.h
index 97887ec78..11bd6ab93 100644
--- a/include/xkbrules.h
+++ b/include/xkbrules.h
@@ -80,10 +80,6 @@ typedef struct _XkbRF_Rules {
 
 _XFUNCPROTOBEGIN
 
-extern _X_EXPORT Bool XkbRF_LoadRules(FILE * /* file */ ,
-                                      XkbRF_RulesPtr    /* rules */
-    );
-
 extern _X_EXPORT XkbRF_RulesPtr XkbRF_Create(void);
 
 extern _X_EXPORT void XkbRF_Free(XkbRF_RulesPtr /* rules */ ,
diff --git a/xkb/xkbrules_priv.h b/xkb/xkbrules_priv.h
index 7e73ec7a3..e498f6ced 100644
--- a/xkb/xkbrules_priv.h
+++ b/xkb/xkbrules_priv.h
@@ -5,6 +5,7 @@
 #ifndef _XSERVER_XKB_XKBRULES_PRIV_H
 #define _XSERVER_XKB_XKBRULES_PRIV_H
 
+#include <stdio.h>
 #include <X11/Xdefs.h>
 
 #include "include/xkbrules.h"
@@ -15,4 +16,6 @@ Bool XkbRF_GetComponents(XkbRF_RulesPtr rules,
                          XkbRF_VarDefsPtr var_defs,
                          struct _XkbComponentNames *names);
 
+Bool XkbRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
+
 #endif /* _XSERVER_XKB_XKBRULES_PRIV_H */
commit d3b328ba4a70bc74f9dde6d004023b185d70beaa
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 10:14:58 2025 +0100

    xkb: unexport XkbRF_GetComponents()
    
    Only used inside xkb/* - not used by any modules, so no need
    to keep maintaining it in public headers.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/include/xkbrules.h b/include/xkbrules.h
index 74473cb24..97887ec78 100644
--- a/include/xkbrules.h
+++ b/include/xkbrules.h
@@ -80,14 +80,6 @@ typedef struct _XkbRF_Rules {
 
 _XFUNCPROTOBEGIN
 
-/* Seems preferable to dragging xkbstr.h in. */
-    struct _XkbComponentNames;
-
-extern _X_EXPORT Bool XkbRF_GetComponents(XkbRF_RulesPtr /* rules */ ,
-                                          XkbRF_VarDefsPtr /* var_defs */ ,
-                                          struct _XkbComponentNames *   /* names */
-    );
-
 extern _X_EXPORT Bool XkbRF_LoadRules(FILE * /* file */ ,
                                       XkbRF_RulesPtr    /* rules */
     );
diff --git a/xkb/ddxLoad.c b/xkb/ddxLoad.c
index e147aabce..8001cb25d 100644
--- a/xkb/ddxLoad.c
+++ b/xkb/ddxLoad.c
@@ -42,6 +42,7 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "os/osdep.h"
 #include "xkb/xkbfile_priv.h"
 #include "xkb/xkbfmisc_priv.h"
+#include "xkb/xkbrules_priv.h"
 
 #include "inputstr.h"
 #include "scrnintstr.h"
diff --git a/xkb/maprules.c b/xkb/maprules.c
index 395b5bfab..83abe8076 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -40,6 +40,9 @@
 #include <X11/Xfuncs.h>
 #include <X11/Xatom.h>
 #include <X11/keysym.h>
+
+#include "xkb/xkbrules_priv.h"
+
 #include "misc.h"
 #include "inputstr.h"
 #include "dix.h"
diff --git a/xkb/xkbrules_priv.h b/xkb/xkbrules_priv.h
new file mode 100644
index 000000000..7e73ec7a3
--- /dev/null
+++ b/xkb/xkbrules_priv.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: MIT OR X11
+ *
+ * Copyright © 2024 Enrico Weigelt, metux IT consult <info at metux.net>
+ */
+#ifndef _XSERVER_XKB_XKBRULES_PRIV_H
+#define _XSERVER_XKB_XKBRULES_PRIV_H
+
+#include <X11/Xdefs.h>
+
+#include "include/xkbrules.h"
+
+struct _XkbComponentNames;
+
+Bool XkbRF_GetComponents(XkbRF_RulesPtr rules,
+                         XkbRF_VarDefsPtr var_defs,
+                         struct _XkbComponentNames *names);
+
+#endif /* _XSERVER_XKB_XKBRULES_PRIV_H */
commit b535fd7a4c4baec990e726fb2c4c00b74c1cc57b
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 10:40:10 2025 +0100

    xkb: move XkbRF_* defines into xkb/maprules.c
    
    Only used there so no need to keep them in public API header.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/include/xkbrules.h b/include/xkbrules.h
index 6be20ea5f..74473cb24 100644
--- a/include/xkbrules.h
+++ b/include/xkbrules.h
@@ -67,11 +67,6 @@ typedef struct _XkbRF_Group {
     char *words;
 } XkbRF_GroupRec, *XkbRF_GroupPtr;
 
-#define	XkbRF_PendingMatch	(1L<<1)
-#define	XkbRF_Option		(1L<<2)
-#define	XkbRF_Append		(1L<<3)
-#define	XkbRF_Normal		(1L<<4)
-
 typedef struct _XkbRF_Rules {
     unsigned short sz_rules;
     unsigned short num_rules;
diff --git a/xkb/maprules.c b/xkb/maprules.c
index a324c67a0..395b5bfab 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -47,7 +47,11 @@
 #include "xkbstr.h"
 #include <xkbsrv.h>
 
-/***====================================================================***/
+
+#define XkbRF_PendingMatch      (1L<<1)
+#define XkbRF_Option            (1L<<2)
+#define XkbRF_Append            (1L<<3)
+#define XkbRF_Normal            (1L<<4)
 
 #define DFLT_LINE_SIZE	128
 
commit 1a9592ea4b37fbdcb7cbf0f72dcde5159cfd6094
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 10:35:05 2025 +0100

    xkb: move _XKB_RF_NAMES_PROP_ATOM define into xkbInit.c
    
    It's only used there, nowhere else, so no need to keep it in
    a public API header.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/include/xkbrules.h b/include/xkbrules.h
index 8f8ad11e7..6be20ea5f 100644
--- a/include/xkbrules.h
+++ b/include/xkbrules.h
@@ -103,9 +103,5 @@ extern _X_EXPORT void XkbRF_Free(XkbRF_RulesPtr /* rules */ ,
                                  Bool   /* freeRules */
     );
 
-/***====================================================================***/
-
-#define	_XKB_RF_NAMES_PROP_ATOM		"_XKB_RULES_NAMES"
-
 _XFUNCPROTOEND
 #endif                          /* _XKBRULES_H_ */
diff --git a/xkb/xkbInit.c b/xkb/xkbInit.c
index fd9c113ab..d3259225f 100644
--- a/xkb/xkbInit.c
+++ b/xkb/xkbInit.c
@@ -50,6 +50,8 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
 #include "scrnintstr.h"
 #include "xkbgeom.h"
 
+#define      _XKB_RF_NAMES_PROP_ATOM         "_XKB_RULES_NAMES"
+
 #define	CREATE_ATOM(s)	MakeAtom(s,sizeof(s)-1,1)
 
 #if defined(__alpha) || defined(__alpha__)
commit 5030f23f943d632416e304365c481d9d67dc70c1
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 10:37:56 2025 +0100

    xkb: drop unused XkbRF_Invalid define from xkbrules.h
    
    Not used anywhere, so no need to keep it in public interface.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/include/xkbrules.h b/include/xkbrules.h
index 0203984fe..8f8ad11e7 100644
--- a/include/xkbrules.h
+++ b/include/xkbrules.h
@@ -71,7 +71,6 @@ typedef struct _XkbRF_Group {
 #define	XkbRF_Option		(1L<<2)
 #define	XkbRF_Append		(1L<<3)
 #define	XkbRF_Normal		(1L<<4)
-#define	XkbRF_Invalid		(1L<<5)
 
 typedef struct _XkbRF_Rules {
     unsigned short sz_rules;
commit 975aed300e0a32118a98a7aaf2a5a0cab26a18e6
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 10:36:10 2025 +0100

    xkb: drop unused _XKB_RF_NAMES_PROP_MAXLEN define
    
    Not used anywhere, so no need to keep it in public header.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/include/xkbrules.h b/include/xkbrules.h
index 8832c01e2..0203984fe 100644
--- a/include/xkbrules.h
+++ b/include/xkbrules.h
@@ -107,7 +107,6 @@ extern _X_EXPORT void XkbRF_Free(XkbRF_RulesPtr /* rules */ ,
 /***====================================================================***/
 
 #define	_XKB_RF_NAMES_PROP_ATOM		"_XKB_RULES_NAMES"
-#define	_XKB_RF_NAMES_PROP_MAXLEN	1024
 
 _XFUNCPROTOEND
 #endif                          /* _XKBRULES_H_ */
commit e38eeb471865b7a7812583d55f8f9991f8a0271a
Author: Enrico Weigelt, metux IT consult <info at metux.net>
Date:   Wed Feb 26 10:28:29 2025 +0100

    xkb: drop unused XkbRF_LoadRulesByName()
    
    Not used anywhere, so no need to keep it around any longer.
    
    Signed-off-by: Enrico Weigelt, metux IT consult <info at metux.net>
    Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1840>

diff --git a/include/xkbrules.h b/include/xkbrules.h
index ab5b4b266..8832c01e2 100644
--- a/include/xkbrules.h
+++ b/include/xkbrules.h
@@ -98,13 +98,6 @@ extern _X_EXPORT Bool XkbRF_LoadRules(FILE * /* file */ ,
                                       XkbRF_RulesPtr    /* rules */
     );
 
-extern _X_EXPORT Bool XkbRF_LoadRulesByName(char * /* base */ ,
-                                            char * /* locale */ ,
-                                            XkbRF_RulesPtr      /* rules */
-    );
-
-/***====================================================================***/
-
 extern _X_EXPORT XkbRF_RulesPtr XkbRF_Create(void);
 
 extern _X_EXPORT void XkbRF_Free(XkbRF_RulesPtr /* rules */ ,
diff --git a/xkb/maprules.c b/xkb/maprules.c
index 0b6c107ae..a324c67a0 100644
--- a/xkb/maprules.c
+++ b/xkb/maprules.c
@@ -963,37 +963,6 @@ XkbRF_LoadRules(FILE * file, XkbRF_RulesPtr rules)
     return TRUE;
 }
 
-Bool
-XkbRF_LoadRulesByName(char *base, char *locale, XkbRF_RulesPtr rules)
-{
-    FILE *file;
-    char buf[PATH_MAX];
-    Bool ok;
-
-    if ((!base) || (!rules))
-        return FALSE;
-    if (locale) {
-        if (snprintf(buf, PATH_MAX, "%s-%s", base, locale) >= PATH_MAX)
-            return FALSE;
-    }
-    else {
-        if (strlen(base) + 1 > PATH_MAX)
-            return FALSE;
-        strcpy(buf, base);
-    }
-
-    file = fopen(buf, "r");
-    if ((!file) && (locale)) {  /* fallback if locale was specified */
-        strcpy(buf, base);
-        file = fopen(buf, "r");
-    }
-    if (!file)
-        return FALSE;
-    ok = XkbRF_LoadRules(file, rules);
-    fclose(file);
-    return ok;
-}
-
 /***====================================================================***/
 
 XkbRF_RulesPtr


More information about the xorg-commit mailing list