Move ISEMPTY to utils.h Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
diff --git a/src/utils.h b/src/utils.h
index cebdcd3..89beca6 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -61,6 +61,12 @@ strdup_safe(const char *s)
return s ? strdup(s) : NULL;
}
+static inline bool
+isempty(const char *s)
+{
+ return s == NULL || s[0] == '\0';
+}
+
/* Compiler Attributes */
#if defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__CYGWIN__)
diff --git a/src/xkbcomp/xkbcomp.c b/src/xkbcomp/xkbcomp.c
index 141a48e..cd5fea3 100644
--- a/src/xkbcomp/xkbcomp.c
+++ b/src/xkbcomp/xkbcomp.c
@@ -28,8 +28,6 @@
#include "rules.h"
#include "parseutils.h"
-#define ISEMPTY(str) (!(str) || (strlen(str) == 0))
-
static XkbFile *
keymap_file_from_names(struct xkb_context *ctx,
const struct xkb_rule_names *rmlvo)
@@ -226,11 +224,11 @@ xkb_map_new_from_names(struct xkb_context *ctx,
struct xkb_rule_names rmlvo = *rmlvo_in;
XkbFile *file;
- if (ISEMPTY(rmlvo.rules))
+ if (isempty(rmlvo.rules))
rmlvo.rules = DEFAULT_XKB_RULES;
- if (ISEMPTY(rmlvo.model))
+ if (isempty(rmlvo.model))
rmlvo.model = DEFAULT_XKB_MODEL;
- if (ISEMPTY(rmlvo.layout))
+ if (isempty(rmlvo.layout))
rmlvo.layout = DEFAULT_XKB_LAYOUT;
file = keymap_file_from_names(ctx, &rmlvo);