summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2013-05-09Add keycode min/max and iteration APIMatthias Clasen1-0/+22
Add three new pieces of API: - xkb_keymap_min_keycode does what it says on the tin - xkb_keymap_max_keycode likewise - xkb_keymap_key_for_each calls the provided function once for every valid key in the keymap Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-05-09Widen keycode range to 8/255 if possible (bug #63390)Daniel Stone2-0/+19
If the keycode range is smaller than 8 → 255, artifically widen it when dumping the keymap as not to displease X. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-04-01Replace flex scanner with a hand-written oneRan Benita11-406/+650
The scanner is very similar in structure to the one in xkbcomp/rules.c. It avoids copying and has nicer error reporting. It uses gperf to generate a hashtable for the keywords, which gives a nice speed boost (compared to the naive strcasecmp method at least). But since there's hardly a reason to regenerate it every time and require people to install gperf, the output (keywords.c) is added here as well. Here are some stats from test/rulescomp: Before: compiled 1000 keymaps in 4.052939625s ==22063== total heap usage: 101,101 allocs, 101,101 frees, 11,840,834 bytes allocated After: compiled 1000 keymaps in 3.519665434s ==26505== total heap usage: 99,945 allocs, 99,945 frees, 7,033,608 bytes allocated Signed-off-by: Ran Benita <ran234@gmail.com>
2013-04-01utils: add {un,}map_file to read an entire fileRan Benita3-23/+122
This wraps the current mmap call and adds a fallback implementation for systems which do not have mmap (e.g. mingw). Signed-off-by: Ran Benita <ran234@gmail.com>
2013-04-01Add scanner-utils.h for common scanner functionsRan Benita2-95/+149
We want to share the same functions for another scanner. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-04-01keymap: add xkb_keymap_new_from_buffer()David Herrmann5-0/+108
The current API doesn't allow the caller to create keymaps from mmap()'ed files. The problem is, xkb_keymap_new_from_string() requires a terminating 0 byte. However, there is no way to guarantee that when using mmap() so a user currently has to copy the whole file just to get the terminating zero byte (assuming they cannot use xkb_keymap_new_from_file()). This adds a new entry xkb_keymap_new_from_buffer() which takes a memory location and the buffer size in bytes. Internally, we depend on yy_scan_{string,byte}() helpers. According to flex documentation these already copy the input string because they are wrappers around yy_scan_buffer(). yy_scan_buffer() on the other hand has some insane requirements. The buffer must be writeable and the last two bytes must be ASCII-NUL. But the buffer may contain other 0 bytes just fine. Because we don't want these constraints in our public API, xkb_keymap_new_from_buffer() needs to create a copy of the input memory. But it then calls yy_scan_buffer() directly. Hence, we have the same number of buffer-copies as with *_from_string() but without the terminating 0 requirement. The explicit yy_scan_buffer() call is preferred over yy_scan_byte() so the buffer-copy operation is not hidden somewhere in flex. Maybe some day we no longer depend on flex and can have a zero-copy API. A user could mmap() a file and it would get parsed right from this buffer. But until then, we shouldn't expose this limitation in the API but instead provide an API that some day can work with zero-copy. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> [ran: rebased on top of my branch] Conflicts: Makefile.am src/xkbcomp/xkbcomp.c
2013-04-01xkbcomp/keymap: silence a gcc warningRan Benita1-1/+1
src/xkbcomp/keymap.c:127:12: error: 'found' may be used uninitialized in this function [-Werror=maybe-uninitialized] Not really, but why not. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-19Add environment overrides for default RMLVODaniel Stone3-5/+103
You can now set default values in the environment, as well as a context option to ignore the environment, e.g. for tests. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-03-18rules: be more paranoid in scannerRan Benita1-16/+9
This can't happen, but better safe than sorry. The optimizations were noticeable but negligible. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18rules: quiet a gcc warningRan Benita1-0/+1
src/xkbcomp/rules.c:620:36: error: 'idx' may be used uninitialized in this function [-Werror=maybe-uninitialized] Can't happen but no harm done. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18state: use stdbool in filtersRan Benita1-32/+32
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keymap: rename xkb_kt_map_entry to xkb_key_type_entryRan Benita6-25/+25
That's a better name and fits more nicely. Also change type->map to type->entries. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18Fix pointer style nitRan Benita4-4/+4
(I really dislike this one for some reason..) Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18Remove file_id entirelyRan Benita4-14/+0
It is not used anymore. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18symbols: remove file_idRan Benita1-26/+18
See previous commits. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18compat: remove file_idRan Benita1-32/+16
See previous commit. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18types: remove file_idRan Benita1-17/+10
See previous commit. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18types: put all copy-to-keymap code in one functionRan Benita1-32/+31
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keycodes: remove KeyNamesInfo::mergeRan Benita1-3/+1
Not used. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keycodes: unwrap KeyNameInfoRan Benita1-32/+24
We don't need the struct any more, it only contains one field now. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keycodes: remove file_idRan Benita1-27/+13
The file_id thing is used to identify the XkbFile some statement originally came from. This is needed to avoid spurious warnings; for example, if you write the same alias twice in a file, that's redundant, and you'd want a warning about it. However if intentionally override it from another file, that's fine, and you shouldn't get a warning. So by comparing the file_id's the needed log verbosity is changed. However, the file_id mechanism is really not needed, because we already have that info! Each KeyNamesInfo corresponds to one XkbFile, so if the conflict occurred while handling that one file -> same_file = true, and if it occurs while merging two Info's -> same_file = false. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keymap: don't use darray for key aliasesRan Benita4-58/+56
With a little tweak to the copy-to-keymap routine in keycodes.c we can use a normal array. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keycodes: don't do unnecessary copies while mergingRan Benita1-49/+52
If 'into' in empty we can just steal 'from'. Also move the alias-merging into the big function, it's nicer this way. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18state: small style fixRan Benita1-11/+13
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18Move a couple of general keymap functions from keycodes.cRan Benita6-86/+47
To get a key by name and resolve an alias - this makes sense for everyone. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keycodes: remove unneeded alias conflict checkRan Benita1-67/+35
This is already checked when adding a new alias and merging aliases, so it can never happen when we get to copying to the keymap. Also the log verbosity decision there is quite useless, we should just warn always and be done with it. So we can remove the file_id from AliasInfo, and collapse the alias functions together. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18xkbcomp: handle XKB file include's betterRan Benita6-117/+75
The 'merge_mode' situation is quite messy, and we've introduced a regression compared to original xkbcomp: when handling a composite include statement, such as replace "foo(bar)+baz(bla)|doo:dee" and merging the entire resulting *Info back into the including *Info, we actually use the merge mode that is set by the last part (here it is "augment" because of the '|'), when we should be using the one set for the whole statement (here "replace"). We also take the opportunity to clean up a bit. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18Build cleanly with clangRan Benita2-7/+1
clang doesn't like the use of typeof with out default flags, so just don't use it. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keymap: abstract a bit over the keymap formatRan Benita6-120/+241
Make it a bit easier to experiment with other formats. Add a struct xkb_keymap_format_operations, which currently contains the keymap compilation and _get_as_string functions. Each format can implement whatever it wants from these. The current public entry points become wrappers which do some error reporting, allocation etc., and calling to the specific format. The wrappers are all moved to src/keymap.c, so there are no XKB_EXPORT's under src/xkbcomp/ anymore. The only format available now is normal text_v1. This is all not very KISS, and adds some indirection, but it is helpful and somewhat cleaner. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18text: some style changesRan Benita1-57/+53
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18text: clean up and fix the *MaskText functionsRan Benita4-77/+57
The snprintf trick that LedStateText and ControlMaskText do cannot work, because you can't use the buffer as an argument to write to itself! (posix at least has 'restrict' there). So those two actually never worked for more than one value (i.e. with a +). Fix that, and do the same cleanup to ModMaskText. Now we have 3 functions which look exactly the same, oh well. Also increase the context text buffer size, you never know. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18More spelling errorsRan Benita4-5/+5
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18parser: also skip 'section' ELEMENTRan Benita1-1/+1
It's for geometry only. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18ast-build: remove malloc_or_dieRan Benita1-82/+93
This should be fixed properly. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keycodes: fix spelling in error messageRan Benita1-1/+1
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18Remove list.hRan Benita1-489/+0
We don't use it anymore and it's easy to add back if needed. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keymap-dump: move writing 'key {}' in symbols to its own functionRan Benita1-100/+107
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keymap-dump: remove some ugly empty linesRan Benita1-6/+6
xkbcomp prints them too, but that's just annoying. Also xkb_keycodes doesn't have it already. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keymap-dump: don't indent after xkb_keymap {Ran Benita1-50/+50
xkbcomp doesn't indent there, so it's easier to diff. Also saves some horizontal space which is sorely needed when looking at these files (especially the xkb_symbols). Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keymap-dump: style cleanupsRan Benita1-74/+45
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18ast: add error handling to XkbFileFromComponentsRan Benita1-24/+32
And try to not repeat ourselves. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18Fix dead assignmentsRan Benita4-22/+17
"Value stored to 'stmt' is never read" "Value stored to 'grp_to_use' is never read" And change 'grp' to 'group' if we're here. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keysym: print unicode keysyms uppercase and 0-paddedRan Benita1-3/+5
Use the same format as XKeysymToString. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18Change some log functions to take ctx instead of keymapRan Benita3-10/+10
They don't need the keymap, only the context. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18keycodes: some minor styleRan Benita1-18/+25
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18action: s/hndlrType/handler_typeRan Benita1-5/+5
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18compat: make it clear which 'dflt' is meantRan Benita1-19/+21
Also s/dflt/default. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18symbols: make it clear which 'dflt' is meantRan Benita1-18/+18
A bit easier at a glance. Also, vowels are cool, so just say 'default'. Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18ast: constify argumentRan Benita2-2/+2
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18symbols: fix bad 'merge' assignmentRan Benita1-1/+1
Bug introduced in 2a5b0c9dc1ad1488ecc6b139fd70e464eb687da6, was causing some keys to be merged incorrectly. Signed-off-by: Ran Benita <ran234@gmail.com>