return isempty(str) ? "-" : str;
}
+static inline bool empty_or_dash(const char *str) {
+ return !str ||
+ str[0] == 0 ||
+ (str[0] == '-' && str[1] == 0);
+}
+
static inline char *startswith(const char *s, const char *prefix) {
size_t l;
if (argc >= 3)
path = argv[2];
- if (isempty(path) || streq(path, "-"))
+ if (empty_or_dash(path))
path = NULL;
determine_compression_from_filename(path);
if (argc >= 3)
path = argv[2];
- if (isempty(path) || streq(path, "-"))
+ if (empty_or_dash(path))
path = NULL;
determine_compression_from_filename(path);
if (argc >= 2)
path = argv[1];
- if (isempty(path) || streq(path, "-"))
+ if (empty_or_dash(path))
path = NULL;
if (argc >= 3)
local = argv[2];
else if (path)
local = basename(path);
- if (isempty(local) || streq(local, "-"))
+ if (empty_or_dash(local))
local = NULL;
if (local) {
if (argc >= 2)
path = argv[1];
- if (isempty(path) || streq(path, "-"))
+ if (empty_or_dash(path))
path = NULL;
if (argc >= 3)
local = argv[2];
else if (path)
local = basename(path);
- if (isempty(local) || streq(local, "-"))
+ if (empty_or_dash(local))
local = NULL;
if (local) {
if (argc >= 2)
path = argv[1];
- if (isempty(path) || streq(path, "-"))
+ if (empty_or_dash(path))
path = NULL;
if (argc >= 3)
local = argv[2];
else if (path)
local = basename(path);
- if (isempty(local) || streq(local, "-"))
+ if (empty_or_dash(local))
local = NULL;
if (local) {
local = l;
}
- if (isempty(local) || streq(local, "-"))
+ if (empty_or_dash(local))
local = NULL;
if (local) {
local = l;
}
- if (isempty(local) || streq(local, "-"))
+ if (empty_or_dash(local))
local = NULL;
if (local) {
}
static const char* strnulldash(const char *s) {
- return isempty(s) || streq(s, "-") ? NULL : s;
+ return empty_or_dash(s) ? NULL : s;
}
static const char* systemd_kbd_model_map(void) {
}
static const char *nullify_dash(const char *p) {
- if (isempty(p))
- return NULL;
-
- if (streq(p, "-"))
- return NULL;
-
- return p;
+ return empty_or_dash(p) ? NULL : p;
}
static int import_tar(int argc, char *argv[], void *userdata) {
if (argc >= 3)
path = argv[2];
- if (isempty(path) || streq(path, "-"))
+ if (empty_or_dash(path))
path = NULL;
if (path) {
if (argc >= 3)
path = argv[2];
- if (isempty(path) || streq(path, "-"))
+ if (empty_or_dash(path))
path = NULL;
if (path) {
local = l;
}
- if (isempty(local) || streq(local, "-"))
+ if (empty_or_dash(local))
local = NULL;
if (local) {
local = l;
}
- if (isempty(local) || streq(local, "-"))
+ if (empty_or_dash(local))
local = NULL;
if (local) {
"[%s:%u] Unknown command type '%c'.", fname, line, action[0]);
/* Verify name */
- if (isempty(name) || streq(name, "-"))
+ if (empty_or_dash(name))
name = mfree(name);
if (name) {
}
/* Verify id */
- if (isempty(id) || streq(id, "-"))
+ if (empty_or_dash(id))
id = mfree(id);
if (id) {
}
/* Verify description */
- if (isempty(description) || streq(description, "-"))
+ if (empty_or_dash(description))
description = mfree(description);
if (description) {
}
/* Verify home */
- if (isempty(home) || streq(home, "-"))
+ if (empty_or_dash(home))
home = mfree(home);
if (home) {
}
/* Verify shell */
- if (isempty(shell) || streq(shell, "-"))
+ if (empty_or_dash(shell))
shell = mfree(shell);
if (shell) {
return -EIO;
}
- if (!isempty(buffer) && !streq(buffer, "-")) {
+ if (!empty_or_dash(buffer)) {
i.argument = strdup(buffer);
if (!i.argument)
return log_oom();
free_and_replace(i.path, p);
}
- if (!isempty(user) && !streq(user, "-")) {
+ if (!empty_or_dash(user)) {
const char *u = user;
r = get_user_creds(&u, &i.uid, NULL, NULL, NULL, USER_CREDS_ALLOW_MISSING);
i.uid_set = true;
}
- if (!isempty(group) && !streq(group, "-")) {
+ if (!empty_or_dash(group)) {
const char *g = group;
r = get_group_creds(&g, &i.gid, USER_CREDS_ALLOW_MISSING);
i.gid_set = true;
}
- if (!isempty(mode) && !streq(mode, "-")) {
+ if (!empty_or_dash(mode)) {
const char *mm = mode;
unsigned m;
} else
i.mode = IN_SET(i.type, CREATE_DIRECTORY, TRUNCATE_DIRECTORY, CREATE_SUBVOLUME, CREATE_SUBVOLUME_INHERIT_QUOTA, CREATE_SUBVOLUME_NEW_QUOTA) ? 0755 : 0644;
- if (!isempty(age) && !streq(age, "-")) {
+ if (!empty_or_dash(age)) {
const char *a = age;
if (*a == '~') {