src/utils.h


Log

Author Commit Date CI Message
Ran Benita e5353528 2012-08-13T13:49:17 Move ISEMPTY to utils.h 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 e037f518 2012-07-21T14:53:49 action: use new log functions Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 2c30fa7a 2012-07-21T16:10:17 Remove old logging leftovers Everything has been converted. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 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>
Ran Benita 71c2f2e0 2012-07-20T17:20:35 utils: replace FATAL by malloc_or_die "Out of memory" is enough in this case. If we want to be OOM-safe this makes it clear where to begin. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 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>
Ran Benita 8b0e9f92 2012-07-20T13:07:30 utils: remove uTypedAlloc/Calloc 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>
Ran Benita cd5a8274 2012-06-06T10:44:22 utils: remove unused recalloc and related macros Their use is superseded by darray everywhere now. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 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>
Ran Benita 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>
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 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>
Ran Benita 813ddf25 2012-03-24T00:29:33 Silence -Wcast-qual warnings There are some cases where we must free a string with a const qualifier. Add a macro UNCONSTIFY to trick the compiler into silencing the warning in the cases where we know what we're doing. 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>
Ran Benita 3104a8ef 2012-03-24T00:12:08 Move utility macro from XKBcommonint.h to utils.h And merge all the similar ones into the same name. The u* prefix is chosen over the _Xkb prefix because it has more uses throughout the codebase. But It should now be simple to choose a nice prefix and stay consistent. Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: fixed for the case where we have strcasecmp]
Ran Benita 861b0c79 2012-03-23T23:47:26 Rewrite recalloc to the correct type The recalloc function should be expressed in terms of bytes to match its name. However uTypedRecalloc retains its type so nothing is changed. Signed-off-by: Ran Benita <ran234@gmail.com>
Ran Benita 0480f427 2012-03-23T23:28:24 Remove useless stuff from utils Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: fixed conflicts from strcasecmp, added includes to make filecomp build again]
Ran Benita d22b8dbb 2012-03-23T22:25:47 Move utils.{c,h} to be used by the entire project This is a first step for making consistent use of utils.h also outside of xkbcomp/ . Signed-off-by: Ran Benita <ran234@gmail.com>