summaryrefslogtreecommitdiff
path: root/src/compose
AgeCommit message (Collapse)AuthorFilesLines
2023-12-22Fix build errorJihoon Kim1-1/+2
Change-Id: Ibaa726eb7ab77b4a9a51a7d3670bd27f8701fcf5 Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
2023-12-22Fix issue detected by static analysis toolJihoon Kim1-1/+1
Because sprintf assumes an arbitrarily long string, callers must be careful not to overflow the actual space of the destination. Change-Id: I4a3e641459d1da0f54db7eeb109447868906e394 Signed-off-by: Jihoon Kim <jihoon48.kim@samsung.com>
2023-12-22table.c: Fix a coverity warning of uninitialized value 'dummy'Duna Oh1-1/+3
2023-12-22fix not to display error log about the absense of compose fileSung-Jin Park1-3/+8
All locale information except 'en_US.UTF-8' had been removed as a part of the uninstallation of unnecessary resources except the essential elements for basic key-mapping funtionality. As a result, if a locale is set to other than 'en_US.UTF-8', an error message is being displayed that says a compose file cannot be found. Actually, there is no problem with the behavior but it is often perceived by the developer(s) and tester(s) as an error. Thus, this fixes the search error for the compose file for another locale other than 'en_US.UTF-8' to not be displayed anymore. Change-Id: I37ead508bda79e71baf5d6743f1f6b059b6010a1 Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
2023-09-26Show invalid escape sequencesPierre Le Marre1-12/+16
It is easier to debug when the message actually displays the offending escape sequence.
2023-09-26Disallow producing NULL character with escape sequencesPierre Le Marre1-4/+15
NULL usually terminates the strings; allowing to produce it via escape sequences may lead to undefined behaviour. - Make NULL escape sequences (e.g. `\0` and `\x0`) invalid. - Add corresponding test. - Introduce the new message: XKB_WARNING_INVALID_ESCAPE_SEQUENCE.
2023-09-26Compose: add iterator APIRan Benita4-3/+166
Allow users to iterate the entries in a compose table. This is useful for other projects which want programmable access to the sequences, without having to write their own parser. - New API: - `xkb_compose_table_entry_sequence`; - `xkb_compose_table_entry_keysym`; - `xkb_compose_table_entry_utf8`; - `xkb_compose_table_iterator_new`; - `xkb_compose_table_iterator_free`; - `xkb_compose_table_iterator_next`. - Add tests in `test/compose.c`. - Add benchmark for compose traversal. - `tools/compose.c`: - Print entries instead of just validating them. - Add `--file` option. - TODO: make this tool part of the xkbcli commands. Co-authored-by: Pierre Le Marre <dev@wismill.eu> Co-authored-by: Ran Benita <ran@unusedvar.com> Signed-off-by: Ran Benita <ran@unusedvar.com>
2023-09-24Messages: merge macros with and without message codePierre Le Marre2-3/+7
Previously we had two types of macros for logging: with and without message code. They were intended to be merged afterwards. The idea is to use a special code – `XKB_LOG_MESSAGE_NO_ID = 0` – that should *not* be displayed. But we would like to avoid checking this special code at run time. This is achieved using macro tricks; they are detailed in the code (see: `PREPEND_MESSAGE_ID`). Now it is also easier to spot the remaining undocumented log entries: just search `XKB_LOG_MESSAGE_NO_ID`.
2023-05-15compose: drop the 65535 node limit (#343)alois313-10/+11
In commit 1638409b22aef33d487863876ab214b949db4984, the number of compose nodes was limited to 65535 to enable "future optimizations", which apparently means slightly reduced memory usage due to fitting in a uint16_t. At this time, it was mentioned that the author was not aware of "any compose files which come close". However, I'm one of the users that actually do require a larger number of nodes for their compose file. Thus, use a uint32_t again and raise the limit significantly.
2022-12-16context: add XKB_CONTEXT_NO_SECURE_GETENV flag (#312)Ronan Pigott4-32/+33
This flag is useful for clients that may have relatively benign capabilities set, like CAP_SYS_NICE, that also want to use the xkb configuration from the environment and user configs in XDG_CONFIG_HOME. Fixes: https://github.com/xkbcommon/libxkbcommon/issues/308 Fixes: https://github.com/xkbcommon/libxkbcommon/issues/129 Signed-off-by: Ran Benita <ran@unusedvar.com>
2022-05-15Do not clear sibling entries when override.Weng Xuetian1-1/+1
lokid and hikid actually stores the sibling to current node, which should not be cleared when override. This would break the sequence with a common prefix when override another. Fix #286 Signed-off-by: Weng Xuetian <wengxt@gmail.com>
2022-03-14scanner: prefix functions with `scanner_` to avoid symbol conflictsRan Benita1-51/+51
Particularly `eof()` in mingw-w64. Fixes: https://github.com/xkbcommon/libxkbcommon/pull/285 Reported-by: Marko Lindqvist Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-05-08compose: add mapped locale to Compose-file-not-found error logRan Benita1-1/+2
Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-04-02compose: fix max compose nodes checkRan Benita1-2/+3
Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-03-31compose: use a ternary tree instead of a regular trieRan Benita4-128/+139
Previously we used a simple trie with a linked list for each chain. Unfortunately most compose files have very long chains which means the constructions performs an almost quadratic number of comparisons. Switch to using a ternary search tree instead. This is very similar to a trie, only the linked list is essentially replaced with a binary tree. On the en_US/Compose file, the perf diff is the following (the modified function is `parse`): Event 'cycles:u' Baseline Delta Abs Shared Object Symbol ........ ......... ................ ................................. 39.91% -17.62% bench-compose [.] parse.constprop.0 20.54% +6.47% bench-compose [.] lex 17.28% +5.55% libc-2.33.so [.] __strcmp_avx2 12.78% +4.01% bench-compose [.] xkb_keysym_from_name 2.30% +0.83% libc-2.33.so [.] __GI_____strtoull_l_internal 3.36% +0.78% bench-compose [.] strcmp@plt Thanks to some careful packing, the memory usage is pretty much the same. Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-03-30compose: use anonymous unionRan Benita4-25/+27
Signed-off-by: Ran Benita <ran@unusedvar.com>
2021-03-30compose: add a limit of 65535 sequencesRan Benita3-10/+18
Fits in uint16_t, which enables some future optimizations. But also a good idea to have some limit. Not aware of any compose files which come close. Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-07-23Make path retrieval consistent in xkb_compose_table_new_from_locale()Emmanuel Gil Peyrot3-15/+13
2020-07-23compose: add xdg base directory supportEmmanuel Gil Peyrot3-0/+29
Before reading ~/.XCompose, try to read $XDG_CONFIG_HOME/XCompose (falling back to ~/.config/XCompose). This helps unclutter the home directory of users who want that.
2020-07-13Add asprintf_safe helper functionPeter Hutterer1-10/+3
We only ever care about whether we error out or not, so let's wrap this into something more sane. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-28Open files in binary modeRan Benita3-5/+5
This turns off some misfeatures on Windows, and does nothing on POSIX. Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27build: include config.h manuallyRan Benita4-0/+8
Previously we included it with an `-include` compiler directive. But that's not portable. And it's better to be explicit anyway. Every .c file should have `include "config.h"` first thing. Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-11-12Replace some tabs that sneaked in with spacesRan Benita1-1/+1
Signed-off-by: Ran Benita <ran@unusedvar.com>
2018-07-30compose: fix infinite loop in parser on some inputsRan Benita1-1/+1
The parser would enter an infinite loop if an unterminated keysym literal occurs at EOF. Found with the afl fuzzer. Signed-off-by: Ran Benita <ran234@gmail.com>
2017-12-12compose/parser: be more careful when checking if sequence overrides or ↵Ran Benita1-3/+15
duplicates another Signed-off-by: Ran Benita <ran234@gmail.com>
2017-04-11Add explicit fallthrough case statementsDaniel Stone1-0/+1
When we fall through to another label in a case, add an explicit comment noting so, to quiet GCC 7's warnings. Signed-off-by: Daniel Stone <daniels@collabora.com>
2016-12-03compose: remove the keysym_from_name cacheRan Benita1-45/+3
The hit rate is high, but either the cache is slow or the function is not fast enough -- the cache no longer holds its weight, leading only to very modest improvements. If it's the former, it can definitely be improved, the code is very dumb (though it worked just as well as any other I tried back then). But instead, let's just kill it. Signed-off-by: Ran Benita <ran234@gmail.com>
2015-11-19src/utils: change map_file to not take const string argumentRan Benita2-3/+4
map_file() uses PROT_READ, so const seems fitting; however unmap_file calls munmap/free, which do not take const, so an UNCONSTIFY is needed. To avoid the UNCONSTIFY hack, which is likely undefined behavior or some such, just remove the const. Signed-off-by: Ran Benita <ran234@gmail.com>
2015-03-24compose: correctly parse modifier syntaxRan Benita1-17/+24
As described in: http://cgit.freedesktop.org/xorg/lib/libX11/commit/?id=ddf3b09bb262d01b56fbaade421ac85b0e60a69f Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-23Reduce variable scopesRan Benita1-4/+2
Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-18Replace some strncmp's with memcmpRan Benita1-2/+2
Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-18compose/parser: save len in keysym_from_name cacheRan Benita1-1/+4
This reduces a lot of strcmp's, and allows to use a faster memcmp. Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-14compose/parser: fix parsing of multiple modifiersRan Benita1-13/+20
Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-13compose/parser: parse (! mods) properlyRan Benita1-15/+91
We don't actually do anything with them. But if someone uses them we can at least not choke. Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-13compose/parser: resolve keysyms in parser instead of scannerRan Benita1-28/+38
It will become context-sensitive. Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-13compose/parser: use parameter as intendedRan Benita1-1/+1
Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-13compose/parser: one more skip_to_eol()Ran Benita1-3/+2
Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-13compose/parser: fix segfault when includingRan Benita1-3/+2
The keysym cache for the new scanner was not initialized. To avoid such errors also in the future, require passing the priv argument in scanner_init(), instead of initializing it separately. Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-13COPYING: add copyright notice from libX11:modules/im/ximcp/imLcPrs.cRan Benita1-0/+31
We have used some portions of it, so add the notice. Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-08scanner-utils: optimize one-line commentsRan Benita1-1/+1
Compose files have a lot of those. Signed-off-by: Ran Benita <ran234@gmail.com>
2014-10-05compose: add xkbcommon-compose - implementationRan Benita7-0/+1431
Signed-off-by: Ran Benita <ran234@gmail.com>