On Tue, 11.11.14 13:29, Jan Synacek (jsyna...@redhat.com) wrote: > >> Hmm, reading the file over and over and over again sounds less than > >> ideal. Maybe we should intrdouce a struct here and then make > >> xkb_get_keymaps() return an array of structs really? > > > > That sounds ok, I'll see what I can do. I wanted to preserve as much of > > the original code as I could, but maybe it wasn't the right decision. > > After thinking about it, I can put the layout and its variants into a > structure, but... When parsing "/usr/share/X11/xkb/rules/base.lst", is > it safe to depend on the ordering of all the components in the file? I > mean, is it safe to expect layouts being order before variants in that > file? Or can it be vice versa? The code would have to be more general if > one cannot depend on that order, and I think it would be quite ugly. The > strv implementation doesn't have that problem.
Writing a parser that doesn't mind about the order doesn't appear too complex to me... Would need a simply state machine that changes state each time one of the "!" headers is encountered. And then, maintain a "Set" for each type of field, and keep adding entries to it, ignoring duplicates. And if you iterate through the variants and find a layout that you haven't seen before just add the layout to the set, too. Lennart -- Lennart Poettering, Red Hat _______________________________________________ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel