summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2016-01-06 21:32:52 +0100
committerPeter Hutterer <peter.hutterer@who-t.net>2016-01-08 10:46:52 +1000
commit8995ac58e15595de9158c2d8df9e02b0c925e8f4 (patch)
treec6dc322b2c2fa3dce72dfdc4147f8b40fc18e0da
parentbf4d7d059daf5c6f81d70f8d3e5e2a87265381b7 (diff)
When a file contains several maps, look for a default map
Rather than always taking the first one in the file. This is exactly the intended use of the 'default' flag. Note that pretty much the same code is duplicated in xkbcomp.c when compiling a single file from the command line, but there it is implemented correctly (look for XkbLC_Default). https://bugs.freedesktop.org/show_bug.cgi?id=69950 Signed-off-by: Ran Benita <ran234@gmail.com> Tested-by: Benno Schulenberg <bensberg@justemail.net> Acked-by: Sergey Udaltsov <sergey.udaltsov@gmail.com> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--misc.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/misc.c b/misc.c
index 4990a74..848ed8c 100644
--- a/misc.c
+++ b/misc.c
@@ -88,6 +88,15 @@ ProcessIncludeFile(IncludeStmt * stmt,
fclose(file);
XkbAddFileToCache(stmt->file, file_type, stmt->path, rtrn);
}
+
+ /*
+ * A single file may contain several maps. Here's how we choose the map:
+ * - If a specific map was requested, look for it exclusively.
+ * - Otherwise, if the file only contains a single map, return it.
+ * - Otherwise, if the file has maps tagged as default, return the
+ * first one.
+ * - If all fails, return the first map in the file.
+ */
mapToUse = rtrn;
if (stmt->map != NULL)
{
@@ -105,12 +114,24 @@ ProcessIncludeFile(IncludeStmt * stmt,
return False;
}
}
- else if ((rtrn->common.next != NULL) && (warningLevel > 5))
+ else if (rtrn->common.next != NULL)
{
- WARN1("No map in include statement, but \"%s\" contains several\n",
- stmt->file);
- ACTION1("Using first defined map, \"%s\"\n", rtrn->name);
+ while ((mapToUse) && !(mapToUse->flags & XkbLC_Default))
+ {
+ mapToUse = (XkbFile *) mapToUse->common.next;
+ }
+ if (!mapToUse)
+ {
+ if (warningLevel > 5)
+ {
+ WARN1("No map in include statement, but \"%s\" contains several without a default map\n",
+ stmt->file);
+ ACTION1("Using first defined map, \"%s\"\n", rtrn->name);
+ }
+ mapToUse = rtrn;
+ }
}
+
setScanState(oldFile, oldLine);
if (mapToUse->type != file_type)
{