if (path_is_absolute(p))
return strdup(p);
- if (!(cwd = get_current_dir_name()))
+ cwd = get_current_dir_name();
+ if (!cwd)
return NULL;
r = path_make_absolute(p, cwd);
errno = 0;
u = canonicalize_file_name(t);
- free(t);
-
if (!u) {
- if (errno == ENOMEM || !errno)
- enomem = true;
-
- continue;
- }
+ if (errno == ENOENT)
+ u = t;
+ else {
+ free(t);
+ if (errno == ENOMEM || !errno)
+ enomem = true;
+
+ continue;
+ }
+ } else
+ free(t);
l[k++] = u;
}
return l;
}
-char **path_strv_remove_empty(char **l) {
- char **f, **t;
+char **path_strv_canonicalize_uniq(char **l) {
+ if (strv_isempty(l))
+ return l;
- if (!l)
+ if (!path_strv_canonicalize(l))
return NULL;
- for (f = t = l; *f; f++) {
-
- if (dir_is_empty(*f) > 0) {
- free(*f);
- continue;
- }
-
- *(t++) = *f;
- }
-
- *t = NULL;
- return l;
+ return strv_uniq(l);
}
char *path_kill_slashes(char *path) {