[PATCH xkbcomp] When a file contains several maps, look for a default map

Peter Hutterer peter.hutterer at who-t.net
Thu Jan 7 16:48:19 PST 2016


On Wed, Jan 06, 2016 at 09:32:52PM +0100, Benno Schulenberg wrote:
> From: Ran Benita <ran234 at gmail.com>
> 
> 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).

any chance for a follow-up patch to share this code?

pushed, thanks.
   bf4d7d0..8995ac5  master -> master

Cheers,
   Peter

> 
> https://bugs.freedesktop.org/show_bug.cgi?id=69950
> 
> Signed-off-by: Ran Benita <ran234 at gmail.com>
> Tested-by: Benno Schulenberg <bensberg at justemail.net>
> Acked-by: Sergey Udaltsov <sergey.udaltsov at gmail.com>
> ---
>  misc.c | 29 +++++++++++++++++++++++++----
>  1 file changed, 25 insertions(+), 4 deletions(-)
> 
> diff --git a/misc.c b/misc.c
> index 4990a74..848ed8c 100644
> --- a/misc.c
> +++ b/misc.c
> @@ -82,41 +82,62 @@ ProcessIncludeFile(IncludeStmt * stmt,
>              setScanState(oldFile, oldLine);
>              ERROR1("Error interpreting include file \"%s\"\n", stmt->file);
>              ACTION("Exiting\n");
>              fclose(file);
>              return False;
>          }
>          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)
>      {
>          while ((mapToUse) && ((!uStringEqual(mapToUse->name, stmt->map)) ||
>                                (mapToUse->type != file_type)))
>          {
>              mapToUse = (XkbFile *) mapToUse->common.next;
>          }
>          if (!mapToUse)
>          {
>              ERROR3("No %s named \"%s\" in the include file \"%s\"\n",
>                     XkbConfigText(file_type, XkbMessage), stmt->map,
>                     stmt->file);
>              ACTION("Exiting\n");
>              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)
>      {
>          ERROR2("Include file wrong type (expected %s, got %s)\n",
>                 XkbConfigText(file_type, XkbMessage),
>                 XkbConfigText(mapToUse->type, XkbMessage));
>          ACTION1("Include file \"%s\" ignored\n", stmt->file);
>          return False;
>      }
> -- 
> 1.8.4
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 


More information about the xorg-devel mailing list