src/xkbcomp/expr.c


Log

Author Commit Date CI Message
Ran Benita cdc228ea 2012-08-13T11:00:43 Organize xkbcomp/ header files Various non-functional changes: - Re-add keycodes.h and move some stuff there. - Add parser-priv.h for internal bison/flex stuff. - Don't include headers from other headers, such that file dependencies are immediate in each file. - Rename xkbcomp.h -> ast.h, parseutils.{c,h} -> ast-build.{c,h} - Rename path.{c,h} -> include.{c,h} - Rename keytypes.c -> types.c - Make the naming of XkbFile-related functions more consistent. - Move xkb_map_{new,ref,unref} to map.c. - Remove most extern keyword from function declarations, it's just noise (XKB_EXPORT is what's important here). - Append XKBCOMP_ to include guards. - Shuffle some code around to make all of this work. Splitting this would be a headache.. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita b2c4331a 2012-07-28T22:15:59 Handle key names consistently We treat the key names as fixed length, non NUL terminated strings of length XkbKeyNameLength, and use the appropriate *Text functions to print them. We also use strncpy everywhere instead of memcpy to copy the names, because it does some NUL padding and we might as well. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 15541766 2012-08-05T14:10:45 expr: make ResolveLevel return zero-based level Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 59d947c9 2012-08-05T19:24:44 Add and use xkb_level_index_t Several types are used over the code for shift levels; better to use just one. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 6f08a2cf 2012-08-03T00:33:40 expr: constify function arguments We need this for later. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 7c7e4341 2012-08-01T11:25:34 Use only one set of core mod name-to-index functions These were repeated 5 times. Note that this changes the ABI slightly: XKB_MOD_NAME_CAPS is changed from "Caps Lock" to "Lock", which is the ordinary legacy mod name for it. Since its hidden behind a #define, it's best to stay compatible with the old names (as I think was intended, given that "Mod1", etc. are the same). Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 41d9afc5 2012-07-27T15:31:03 Remove ExprResult Convert the IdentLookup typedef away from ExprResult, which drags along everything else. This should also make all of the conversions explicit. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 6917901f 2012-07-27T14:15:39 expr: remove support for evaluating string as integer As the comment nicely puts it, this is a bit weird. When you try to evaluate an expression of type string into an integer, what it does is: "" -> 0 "c" -> (ascii value, i.e. like a char literal) more than one char -> error The first one is obviously not very useful; why not just write 0? The second one might be useful (though I don't see where in a keymap it would be), but I don't think anyone would consider trying "X" for that anyway. A look through xkeyboard-config shows "" only used once as a string, and "X" also only used as strings (and mostly in geometry which we don't evaluate anyway). And I seriously doubt it's used (purposely) anywhere else. So remove it. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita bd927abf 2012-07-24T19:39:59 expr: drop ExprResult from ResolveEnum Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 38614c88 2012-07-24T17:21:29 expr: drop ExprResult from ResolveMask Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 2e4933cd 2012-07-24T10:39:15 expr: drop ExprResult from ResolveInteger Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita d5682289 2012-07-24T01:22:26 expr: drop ExprResult from ResolveButton Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 6ec13570 2012-07-24T00:51:19 expr: drop ExprResult from ResolveLevel Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 000528dd 2012-07-24T00:23:34 expr: drop ExprResult from ResolveKeyCode Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita e258f9ee 2012-07-24T00:10:07 expr: drop ExprResult from ResolveGroup Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 70262292 2012-07-23T23:56:28 expr: drop ExprResult from ResolveKeysym Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 0d262fa1 2012-07-23T19:52:17 expr: drop ExprResult from ResolveBoolean Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 27f94929 2012-07-23T15:46:50 expr: drop ExprResult from ResolveString Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 025ca579 2012-07-23T12:20:05 expr: drop ExprResult from ResolveLhs Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 761b675c 2012-07-23T11:56:13 expr: drop ExprResult from ResolveKeyName Explicit is better than implicit, and this union makes it hard to follow what's what, particularly the confusion with ival/uval. The other Resolve functions will follow. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 724f62c8 2012-07-25T17:29:08 Convert defines to enums in xkbcomp.h For statement / expression types. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 89723b7c 2012-07-24T19:54:14 utils: add/replace string equality macros It's more tidy and less error prone, since we use strcasecmp == 0 a lot. We replace strcmp == 0 by streq, strcasecmp == 0 by istreq, uStrCasePrefix by istreq_prefix and uDupString by strdup_safe. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 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>
Ran Benita c6279b8b 2012-07-23T21:21:03 expr: don't divide by zero Calculator parser 101. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 2e245a9a 2012-07-23T11:42:22 expr: Remove ExprResolveFloat Remnant from geometry. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita d659f2b4 2012-07-21T15:12:31 expr: use new log functions Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 50b25a12 2012-07-17T11:03:43 Use xkb_group_index_t for group variables throughout Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 7d9f0313 2012-07-15T13:00:04 Get rid of struct xkb_key_name Just embed it directly. Signed-off-by: Ran Benita <ran234@gmail.com>
Daniel Stone 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>
Daniel Stone 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>
Daniel Stone 6433d72e 2012-05-09T20:12:12 Merge remote-tracking branch 'krh/keysyms' Conflicts: src/keysym.c src/misc.c src/text.h src/xkbcomp/expr.c src/xkbcomp/parser.y src/xkbcomp/parseutils.c src/xkbcomp/symbols.c Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Kristian Høgsberg ace1e5df 2012-05-09T09:05:00 Use our own keysyms
Ran Benita 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.]
Ran Benita cdd2906d 2012-05-09T13:50:05 Make the context available for XkbcAtomText And rename the function to xkb_atom_text. Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: Updated for xkb -> keymap.]
Ran Benita 8d680e80 2012-05-09T12:01:03 Make the context available for XkbcAtomGetString In preparation of contextualizing atom handling. Since we touch every function call, we also rename the function to xkb_atom_strdup to match xkb_atom_intern, and be more descriptive. Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: Updated for xkb -> keymap.]
Daniel Stone 38cb6390 2012-05-09T15:15:30 Change all 'xkb' xkb_keymap names to 'keymap' To make it a bit more clear what it actually is. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone e1af48bc 2012-05-09T13:22:34 Rename keysym <-> string API Change them to refer to the string representation of the keysym's name as a name rather than a string, since we want to add API to get the Unicode printable representation as well. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Ran Benita 33273304 2012-05-08T13:57:07 Rename xkbcomp/misc.h to xkbcomp-priv.h and use it The include dependencies were quite convoluted, where you change the order and get a ton of errors. Instead, change one file to act as the internal interface for the xkbcomp files, and make every file use it. Also drop the pointless "xkb" prefix to file names. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita a641a185 2012-04-06T03:38:55 Use stdbool.h 'Cause defining your own True and False is so 1990's. Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: Fixed for xkb_desc -> xkb_keymap changes.]
Ran Benita a39ed85f 2012-04-05T11:24:39 Fix formatting in xkbcomp headers Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: Fixed for xkb_desc -> xkb_keymap change.]
Daniel Stone ef88c7ef 2012-04-03T15:14:16 Rename xkb_desc to xkb_keymap struct xkb_desc was just a hangover from the old XkbDescRec, which isn't a very descriptive name. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone bc8bbf50 2012-03-27T15:50:59 Fix build for X11 modifier masks Exposed by include path changes, oops. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Ran Benita 602e8780 2012-03-24T13:27:48 Define our own NoSymbol value and use it Since we have our own xkb_keysym_t type, it makes sense to have our own NoSymbol value instead of the one from X11/X.h. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita d3908b63 2012-03-24T12:33:28 Define our own None atom value Since we define our own xkb_atom_t type, it makes sense not to use the X11/X.h None value. This way we can also remove a lot of X11 includes. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita f08ce9b7 2012-03-24T00:26:12 Use strcasecmp consistently instead of uStrCaseCmp There's no use calling the same thing by a different name. Signed-off-by: Ran Benita <ran234@gmail.com>
Daniel Stone 9468d84a 2012-03-21T14:44:16 Fix (correct, but harmless) const warning Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone f44eed3e 2012-03-21T00:33:29 Remove unnecessary allocation in expr.c Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 937d4049 2012-03-15T09:33:56 Remove more float support Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 9dde0f33 2012-03-13T12:46:37 Revert "Use XKB_COMMON_* modifier defines in ExprResolveModMask" Because indices and masks are not at all the same thing. This reverts commit 645275406f47369c9a67d02173aedf89e9d2a33c.
Daniel Stone 64527540 2012-03-10T14:42:30 Use XKB_COMMON_* modifier defines in ExprResolveModMask Rather than the ones from XKB.h. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 24c61d0f 2012-03-10T14:27:06 Remove half-implemented radio groups It looks like this could never have worked anyway, what with num_rg always being 0 everywhere. Remove it. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone a0e756fd 2012-03-09T19:09:25 Introduce xkb_atom_t type Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 0bb24c2d 2012-03-09T19:03:59 Introduce xkb_keysym_t type Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone ed18e65e 2012-03-05T15:07:28 Merge remote-tracking branch 'ran/fixes-cont' Conflicts: src/xkbcomp/expr.c Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 65e1ff2f 2012-03-05T15:00:39 Merge remote-tracking branch 'ran/fixes'
Ran Benita d2c3dd0c 2012-03-02T22:31:29 Constify some more text functions Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita eb738b13 2012-03-02T17:40:19 Constify global tables Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 266dfae5 2012-02-29T21:26:28 Remove useless casts Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita f3e4335f 2012-02-24T16:07:17 Fix all constness warnings These are all trivial/obvious fixes which clear a bunch of warnings. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita a0dd0526 2012-02-25T11:46:12 Remove unused includes of "tokens.h" Signed-off-by: Ran Benita <ran234@gmail.com>
Daniel Stone 90f04e04 2012-02-20T18:07:29 Perform bounds checking in ExprResolveLevel Both callers perform the same bounds check, so move it into ExprResolveLevel itself. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 1ab058bb 2012-02-20T17:47:46 Fix typo in ExprResolveKeyCode Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone e209fe31 2012-02-20T17:33:39 Perform bounds checking in ExprResolveGroup Every caller did the exact same check on the group bounds after calling ExprResolveGroup, so might as well do it inside. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 43ed3ff0 2012-02-20T17:14:04 Switch expression resolution priv from char to void Avoids a lot of really lame casts. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone eb6d9a05 2012-02-20T17:09:06 Remove chaining support from LookupModMask Turns out we never use it, so. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 11ea0791 2012-02-20T17:07:48 Invert LookupModMask/LookupVModMask order We never want to solely lookup a virtual modifier without also looking up core modifiers. So, rather than chaining the vmod lookup inside the core modifier lookup, invert the ordering. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 1a2f2556 2012-02-20T17:00:51 Remove unused LookupPriv::priv Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 55e058f8 2012-02-20T16:59:51 Move some definitions from expr.h to expr.c Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 90d86c36 2012-02-20T16:54:54 Remove field reference lookup support None of the lookup functions anyone ever used supported field references, so don't pretend we do in the API. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 91b89852 2012-02-20T16:24:02 Turn ExprResolveInteger into a simple wrapper Move the bulk of ExprResolveInteger into an internal function called ExprResolveIntegerLookup, and introduce ExprResolveInteger as a simple wrapper which doesn't take priv/lookup arguments. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone e314931e 2012-02-20T15:47:57 Add ExprResolveGroup helper Just a dumb wrapper around ExprResolveInteger. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 8b47dbbf 2012-02-20T15:47:38 Add ExprResolveButton helper Just a dumb wrapper around ExprResolveInteger. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 3431a089 2012-02-20T15:37:53 Introduce ExprResolveLevel helper Which returns an integer representing the level number represented by the given expression. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 193e9b39 2012-02-20T15:33:40 Introduce ExprResolveRadioGroup helper Just a tiny special-cased version of ExprResolveInteger. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 26285a7b 2012-02-20T14:15:08 Remove priv arguments from ExprResolveString They've never been used. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone b7b49eb0 2012-02-20T14:10:41 Remove priv arguments from ExprResolveKeySym They've never been used by its one caller. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 70033b13 2012-02-20T14:08:55 Remove priv arguments from ExprResolveKeyName They've never been used. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 482d4faa 2012-02-20T13:44:27 Remove priv arguments from ExprResolveBoolean They've never been used. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 94041575 2012-02-20T13:40:34 Remove priv arguments from ExprResolveFloat They've never been used. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 3151ce36 2012-02-20T13:34:36 Remove priv arguments from ExprResolveModMask What with them now being unused and all. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 67605d2c 2012-02-20T13:32:09 Introduce ExprResolveVModMask Which is just a slightly more typesafe wrapper around the chained ExprResolveModMask everyone was using earlier. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone c45cdb0c 2012-02-16T00:22:11 Still more memory leak fixes Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 4e228511 2012-02-15T14:34:08 Introduce xkb_keycode_t for keycodes And use it consistently everywhere, including with a special long-safe internal keycode type, to ease the transition to large keycodes. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Adam Jackson 73ca959d 2010-09-27T16:05:52 Dead code removal and static markup Signed-off-by: Adam Jackson <ajax@redhat.com>
Kristian Høgsberg 3f0034a9 2010-07-02T11:50:01 Rename public entry points to lowercase and underscore
Kristian Høgsberg e10e16ad 2010-06-30T17:20:56 Constify XkbcAtomText() Atoms aren't mutable and this lets us put tbGetBuffer() back in the box.
Kristian Høgsberg 399d4bd6 2010-06-28T06:58:01 Drop malloc wrappers
Kristian Høgsberg 47d3b396 2010-06-28T06:50:12 Drop CARD32 and Opaque types
Daniel Stone 7257d4c8 2010-06-21T14:28:34 Use CARD32 instead of Atom, move geom headers in Use CARD32 instead of Atom/KeySym/et al to avoid type size confusion between server and non-server code; relatedly, move the geometry headers in from kbproto, so every non-simple type (i.e. structs containing nothing more than basic types) is now copied into xkbcommon. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 60e7eeeb 2010-06-17T03:16:09 Use CARD32 instead of Atom, drag in XkbClientMapRec On 64-bit architectures, XID varies in size between the server (always 32 bits), and non-server (always unsigned long) for some inexplicable reason. Use CARD32 instead to avoid this horrible trap. This involves dragging in XkbClientMapRec so we don't get stuck in the KeySym trap. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Daniel Stone 8904c6ee 2010-06-15T15:22:05 xkbcomp: expr: Use XkbcAtomText instead of GetString This returns us a temporary string, rather than leaking the atom. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Dan Nicholson 6a84a34d 2009-04-08T07:46:25 Remove all non-public API from XKBcommon.h header The noble intention was to expose all the new API and new generic types in the split out kbproto headers through XKBcommon.h. It turns out that would be a massive amount of work in the server. Someday, but first just wedging in XkbCompileKeymap* would be good. Most of the API is in new internal xkb*.h headers. In order to allow the XKBcommon.h header to be used from the server, we can't pull in other headers from kbproto since the server has its own copies. However, types that are different (XkbDescRec, XkbAction) still have Xkbc equivalents here, and I think they should be used in the server.
Dan Nicholson 5c910623 2009-04-04T09:19:51 Remove trailing spaces in source files
Dan Nicholson a27e56b6 2009-03-31T07:21:20 xkbcomp: Remove duplicated macros
Dan Nicholson b0acc97a 2009-03-28T12:03:35 xkbcomp: s/XStringToKeysym/XkbcStringToKeysym/
Dan Nicholson 2671b777 2009-03-28T14:06:26 Add more *Text functions from xkbfile This should cover all the usage in xkbcomp. The format arguments were dropped except for the special case of XkbModMaskText, which needs to write in XkbCFile format in HandleVModDef. This was just changed to a Bool to avoid the need for the macros in XKBfile.h. The function prefixes have been renamed to be unique from xkbfile.
Dan Nicholson 8544cde5 2009-03-28T06:56:26 xkbcomp: Drop unused Display argument in Atom functions The xkbcommon Atom implementation doesn't take Display into account.
Dan Nicholson 4fe322aa 2009-03-27T20:13:22 libxkbcomp: s/XPointer/char */ Replace XPointer with its definition since we don't have the privilege of using Xlib.h. Why this is char * and not void *, I'll never know.
Dan Nicholson 18337008 2009-03-27T20:58:27 libxkbcomp: Use the internal Atom implementation s/XkbInternAtom/XkbcInternAtom/ and s/XkbAtomGetString/XkbcAtomGetString/
Dan Nicholson 0c1bbb05 2009-03-27T06:55:32 Import xkbcomp sources for CompileKeymap A copy of the xkbcomp sources (except the frontend) have been copied in to provide a means to compile a XkbDescPtr. This definitely doesn't build or do the right thing yet.