|
5354dee2
|
2019-08-05T13:52:18
|
|
MSVC: Use <io.h> as an alternative for <unistd.h>
Only the input/output functions from <unistd.h> options are used, so
using <io.h> when building with MSVC should be enough. The inclusion
of the header in context-priv.c does not seem to be needed (tested
on GNU/Linux) and so it is removed.
Signed-off-by: Ran Benita <ran@unusedvar.com>
|
|
40aab05e
|
2019-12-27T13:03:20
|
|
build: include config.h manually
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>
|
|
67b538dd
|
2019-09-30T15:39:08
|
|
context: add a helper function to return the default system include path
No functional changes but we'll need that same lookup in the rules file
include handling in a future patch.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
|
|
e23f1061
|
2019-10-25T14:36:16
|
|
Use XDG_CONFIG_HOME as first XKB search path
Use $XDG_CONFIG_HOME/xkb as the primary lookup path for XKB rules. Same
motivation as in 3a91788d9254b, however the XDG directories are more standard
and recommended these days than application-specific dotfiles.
The XDG spec says to fall back to $HOME/.config where XDG_CONFIG_HOME is not
set so we implement that behavior as well.
Fixes #112
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
|
|
4b378398
|
2019-10-20T19:06:19
|
|
context: Don't fail to create the context if HOME isn't available
E.g. when Mutter has CAP_SYS_NICE and thus secure_getenv returns NULL.
Fixes https://bugs.archlinux.org/task/64191
[ran: changed to ignore error]
Signed-off-by: Ran Benita <ran@unusedvar.com>
|
|
3a91788d
|
2019-10-03T17:27:00
|
|
context: move ~/.xkb to before XKB_CONFIG_ROOT in the default include path
Previously, the default include path was XKB_CONFIG_ROOT:~/.xkb.
The ~/.xkb include path is intended to allow the local user to customize
their keymaps without having to modify system paths.
But usually, the user only wants to customize specific parts. When
XKB_CONFIG_ROOT is first, the user can only customize through the "entry
point" (the RMLVO). When ~/.xkb is first, the user can drop in a file
and it will override the system one.
The impetus for this change is the rules file. "evdev" is hard-coded
everywhere, so it not often not possible to change to something else.
And the rules files determines how the rest of the RMLVO is interpreted.
So, to enable customization, we have these options:
A: System includes user.
B: User includes system.
C: Library goes over both in one or the other order.
Option A is problematic due to backward compatibility and is also
unnatural.
Option B gives the user control and is backward compatible, so that's
what we choose. This is also how Compose files are handled, and that
seems to work fine in the wild.
Option C is actually less flexible than B, and more complicated.
(The rules file format doesn't have an include statement yet, but it's
planned).
Signed-off-by: Ran Benita <ran@unusedvar.com>
|
|
7ea129fb
|
2015-07-17T20:59:52
|
|
Add XKB_CONFIG_ROOT environment
The XKB_CONFIG_ROOT environment allows overrding the build time
DFLT_XKB_CONFIG_ROOT path.
|
|
109fe705
|
2014-02-04T02:53:05
|
|
Use secure_getenv when available
We probably don't want to get a privileged process to compile arbitrary
keymaps. So we should be careful about the envvars which control include
paths or default RMLVOs. But then secure_getenv is more sensible for
everything we do.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
a9c56f64
|
2014-01-13T17:20:54
|
|
context: split private functions to context-priv.c
(Same as keymap-priv.c).
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
917c7515
|
2014-01-12T14:37:39
|
|
context: remove mostly useless log wrappers
Just use xkb_log directly.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
58345f4e
|
2013-12-02T14:14:41
|
|
atom: drop {xkb_,}atom_strdup
Even though in 112cccb18ad1bc877b3c4a87fa536ea085c761b5 I said it might
be useful, it's not. So remove it.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
dcdd4e10
|
2013-10-14T18:59:53
|
|
Replace ctype.h functions with ascii ones
ctype.h is locale-dependent, so using it in our scanners is not optimal.
Let's be deterministic with our own simple functions.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
c0589be6
|
2013-07-28T23:42:35
|
|
log: change the log prefixes to be more library-like
"Error: " is not very informative when intermingled with other logs. The
format that seems most suitable is:
"xkbcommon: ERROR: %s"
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
9e801ff7
|
2013-07-21T17:01:20
|
|
ctx: adapt to the len-aware atom functions
xkb_atom_intern now takes a len parameter. Turns out though that almost
all of our xkb_atom_intern calls are called on string literals, the
length of which we know statically. So we add a macro to micro-optimize
this case.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
7e0ae4b4
|
2013-07-21T16:41:27
|
|
atom: allow interning non-NUL-terminated strings
We need this later. The strlen was calculated anyway, so no loss here.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
fbe5e675
|
2013-02-28T10:48:40
|
|
Add environment overrides for default RMLVO
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>
|
|
56ba9866
|
2013-03-04T14:16:36
|
|
Remove file_id entirely
It is not used anymore.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
4e8dcca8
|
2013-03-01T18:33:40
|
|
text: clean up and fix the *MaskText functions
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>
|
|
7261f404
|
2012-10-29T01:00:27
|
|
state, context: allow passing NULL to *_unref()
For error handling code, it's nice to be able to pass NULL to these
function without worrying about segfaults ensuing. free() sets the
precedent here.
Also document this fact.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
714e95e1
|
2012-10-18T22:51:10
|
|
Contextualize GetBuffer()
Instead storing the buffer in a non-thread-safe static array, we move it
to the context.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
523e46f4
|
2012-10-12T10:15:43
|
|
Change log env vars to XKB_LOG_LEVEL/VERBOSITY
A bit more consistent and descriptive.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
0dd40125
|
2012-09-22T10:58:00
|
|
API: add _context prefix to log-related functions
This is to follow the general scheme set by all of the other API
functions.
Since no one is using these functions yet, we don't (actually better
not) add the old names to xkbcommon-compat.h.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
b2110705
|
2012-09-16T14:45:32
|
|
Organize src/ and test/ headers
- Add context.h and move context-related functions from xkb-priv.h to
it.
- Move xkb_context definition back to context.c.
- Add keysym.h and move keysym upper/lower/keypad from xkb-priv.h to it.
- Rename xkb-priv.h to map.h since it only contains keymap-related
definitions and declarations now.
- Remove unnecessary includes and some and some other small cleanups.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
e670d084
|
2012-09-16T13:33:09
|
|
include: improve file-not-found error reporting
Only report it once, and not only for rules.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
b4b40d73
|
2012-09-12T16:54:07
|
|
Copyright updates
With Dan Nicholson's permission (via email), update his copyright and
license statements to the standard X.Org boilerplate MIT license, as
both myself and Ran have been using.
Clean up my copyright declarations (in some cases to correct ownership),
and add copyright/license statements from myself and/or Ran where
appropriate.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
7aa31097
|
2012-08-31T18:52:26
|
|
atom: add xkb_atom_lookup
This will only lookup the string and return the atom if found; it will
not intern it if not. This is useful when e.g. getting a string from the
user (which may be arbitrary) and comparing against atoms.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
8d7d9792
|
2012-08-28T00:42:59
|
|
log: replace "priority" by "level" everywhere
Now that we don't use syslog, "level" does sound more commonplace. We
should change it while there is still nobody using it.
Also leave some space between the integers of the xkb_log_level enum
values, if we ever need to shove more in between.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
3d305bd0
|
2012-08-30T13:49:23
|
|
vmod: remove outdated comments
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
5e276adb
|
2012-08-08T14:01:46
|
|
Add xkb_log_level enum rather than using syslog
Instead of relying on people including syslog.h, add our own
XKB_LOG_LEVEL_* defines.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
3e8370b0
|
2012-08-03T03:11:19
|
|
context: Maintain list of failed include paths
Keep around a list of paths we tried to add but couldn't.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
226cb22c
|
2012-08-03T03:12:52
|
|
Move xkb_context struct to xkb-priv.h
So we can print more intelligent debugging messages without needing
helper functions for the failed_includes array.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
f2ecd665
|
2012-08-06T20:04:22
|
|
log: allow to resore default log function
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
dd0f3c6d
|
2012-07-25T10:53:36
|
|
Don't create contexts with no include paths
Clean up the return code handling from
xkb_context_add_include_paths_default, and thus fail context creation if
we can't add any of the default include paths, but were asked to. If
this happens, dump the DFLT_XKB_CONFIG_ROOT out in the log message, so
at least we know what we aren't looking at.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
112cccb1
|
2012-07-23T16:03:34
|
|
Some atom related optimizations
We often get a strdup'd string, just to pass it over the atom_intern and
then immediately free it. But atom_intern then strdup's it again (if
it's not interned already); so instead we can have the interning "steal"
the memory instead of allocing a new one and freeing the old one. This
is done by a new xkb_atom_steal function.
It also turns out, that every time we strdup an atom, we don't actually
modify it afterwards. Since we are guaranteed that the atom table will
live as long as the context, we can just use xkb_atom_text instead. This
removes a some more dynamic allocations.
For this change we had to remove the ability to append two strings, e.g.
"foo" + "bar" -> "foobar"
which is only possible with string literals. This is unused and quite
useless for our purposes.
xkb_atom_strdup is left unused, as it may still be useful.
Running rulescomp in valgrind, Before:
==7907== total heap usage: 173,698 allocs, 173,698 frees, 9,775,973 bytes allocated
After:
==6348== total heap usage: 168,403 allocs, 168,403 frees, 9,732,648 bytes allocated
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
2c30fa7a
|
2012-07-21T16:10:17
|
|
Remove old logging leftovers
Everything has been converted.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
58f8d2c1
|
2012-07-20T17:09:49
|
|
utils: remove Xfuncproto.h and use our own macros
Add XKB_EXPORT to replace _X_EXPORT, and copy the definitions of
_X_ATTRIBUTE_FOO as ATTR_FOO.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
70f35cfb
|
2012-07-20T13:10:13
|
|
Add logging API
Add new public API to provide the library users with some options to
control and customize the logging output from the library. It is based
upon the skeleton from the libabc demo libray:
https://git.kernel.org/?p=linux/kernel/git/kay/libabc.git
which is public domain and works pretty well.
This requires passing in the context object in every logging call, and
thus the conversion is done file by file. We also remove the global
warningLevel variable in favor of a verbosity level in the context,
which can be set by the user and is silent by default.
One issue is the ACTION calls, which, while nice, do not play very well
with line- and priority-based logging, and would require some
line continuation handling or keeping state or some other compromise. So
instead remove these and just inline them with their respective
warning/error. So instead of:
ERROR("Memory allocation failed\n")
ACTION("Removing all files on hardisk\n")
its something like that:
log_err("Memory allocation failed; Removing all files on harddisk\n")
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
9308a460
|
2012-07-17T10:20:15
|
|
Run source tree through uncrustify
.uncrustify.cfg committed for future reference also, but had to manually
fix up a few things: it really likes justifying struct initialisers.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
43bf4136
|
2012-07-14T15:19:12
|
|
Fix fileID mess
A few problems here:
* In e.g. keycodes.c the fileID field of the Info struct was never
initialized to the id of the appropriate file, so it was always 0.
There's some code which uses it, mostly for warnings.
* Some of the fileID fields were unsigned char, which overflows several
times, seeing as the ID in some of our tests can get > 1000 (because
we reuse the context).
* Some sign mismatches.
* fileID vs file_id.
Hopefully this fixes everything. I doubt this stuff had ever worked as
intended, in xkbcomp or otherwise.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
d0288bb2
|
2012-05-22T00:37:53
|
|
context: use darray for include paths
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
75ff2cef
|
2012-05-13T18:45:43
|
|
Various static analyzer fixes
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
8bdef139
|
2012-05-15T15:23:41
|
|
Use eaccess() only if available
Fixes build on Android.
Signed-off-by: Pekka Paalanen <ppaalanen@gmail.com>
|
|
7b00485a
|
2012-05-11T15:03:43
|
|
Rename 'ctx' back to 'context' in external API
Still keep things as 'ctx' internally so we don't have to worry about
typing it too often, but rename the user-visible API back as it was
kinda ugly.
This partially reverts e7bb1e5f.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
e7bb1e5f
|
2012-05-09T15:03:11
|
|
Shorten context to ctx
(This breaks the API.)
"context" is really annoying to type all the time (and we're going to
type it a lot more :). "ctx" is clear, concise and common in many other
libraries. Use it!
Signed-off-by: Ran Benita <ran234@gmail.com>
[daniels: Fix for xkb -> keymap change.]
|
|
699a0b84
|
2012-05-09T14:02:26
|
|
Contextualize the atom table
Each context gets its own table, i.e. interning a string in one context
does not affect any other context.
The existing xkb_atom_* functions are turned into wrappers around a new
standalone atom_table object.
Signed-off-by: Ran Benita <ran234@gmail.com>
[daniels: Updated for xkb -> keymap.]
|
|
4aef083e
|
2012-05-09T11:29:04
|
|
Contextualize XkbFile IDs
Currently the IDs are assigned from a static variable inside
CreateXKBFile. This can lead to some unpleasantness with threads, so
maintain the counter in the context instead.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
2a0f1780
|
2012-05-08T17:52:45
|
|
Add context flag to inhibit default include paths
Which will make the context start with no include paths at all.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
c3584280
|
2012-05-08T17:51:16
|
|
Add flags to context creation
None defined as yet, but why not.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
b610b2b9
|
2012-05-08T14:52:23
|
|
Rename XKBcommonint.h to xkb-priv.h and use it
Make the files in the src/* directory use their own header or a
consilidated private header. This makes the file dependencies clearer.
Also drop the pointless "xkb" file name prefix, add split a few
declarations to their own files (atom.h and text.h).
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
5eb0a70e
|
2012-05-07T14:44:30
|
|
Don't use typeof
clang complains with the xorg-macros warning flags:
src/context.c:58:36: error: extension used [-Werror,-pedantic,-Wlanguage-extension-token]
typeof(new_paths));
This was not entirely correct, too. So bring back the casts to the
results of the allocation macros; might as well make them a bit more
type safe.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
8fbd44fd
|
2012-04-06T03:12:50
|
|
Implicitly include config.h in all files
The definitions in config.h should be available in all files an
implementation detail; it can be included through the build system
instead of having each file pull it every time.
This is especially helpful with AC_USE_SYSTEM_EXTENSIONS, as _GNU_SOURCE
and friends can have an effect by merely being defined, which can lead
to some confusion if its effective for only half the files.
And we don't really support a build _without_ config.h; so, one less
thing to worry about.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
18e6a6a4
|
2012-04-05T10:47:43
|
|
Remove Xfuncproto.h and XKB.h from xkbcommon/xkbcommon.h
The kbproto header is already not needed here anymore.
Move the _X_EXPORT's to the corresponding function definitions, and use
straight extern "C" clauses instead of _XFUNCPROTOBEGIN/END.
It also makes more sense to have the EXPORT's in the source files, as it
provides some documentation to the reader, whereas in the header it's
obvious.
Signed-off-by: Ran Benita <ran234@gmail.com>
[daniels: Updated for xkb_keymap changes.]
|
|
467d7bb6
|
2012-04-05T10:13:24
|
|
Implement missing xkb_state_ref and add return value
xkb_state_ref was missing.
Also modify the _ref functions to return the object instead of being
void. This is a useful idiom:
struct my_object my_object_new(struct xkb_state *state)
{
[...]
my_object->state = xkb_state_ref(state);
[...]
}
Essentially "taking" a reference, such that you don't forget to
increment it and it's one line less (see example in our own code).
A case could also be made for _unref to return the object or NULL, but
this is quite uncommon.
Signed-off-by: Ran Benita <ran234@gmail.com>
[daniels: Updated for xkb_keymap changes.]
|
|
632d9f03
|
2012-04-03T14:26:04
|
|
Eliminate remaining gcc warnings
Various one-liners (mostly removing unused variables) to make the code
safe for the full set of warnings used by the xorg macros.
On Debian-based systems, flex generates incorrect code resulting in two
warnings about yy_getcolumn and yy_setcolumn having no previous
declaration despite being non-static. Fedora carries a patch to fix
this, and a bug has been filed on Debian's flex to add the patch:
http://bugs.debian.org/667027
Aside from this, it's now safe for --enable-strict-compilation.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
aa9f2bf9
|
2012-03-29T01:41:40
|
|
Don't leak include_paths in context
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
034ffce6
|
2012-03-27T17:22:35
|
|
Use xkb_contexts in keymap compilation
Primarily for the include path, but also for the logging in future.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
3e9dd751
|
2012-03-27T16:59:01
|
|
Add new context API
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|