path-util: introduce path_simplify()
The function is similar to path_kill_slashes() but also removes initial './', trailing '/.', and '/./' in the path. When the second argument of path_simplify() is false, then it behaves as the same as path_kill_slashes(). Hence, this also replaces path_kill_slashes() with path_simplify().
This commit is contained in:
@@ -1599,8 +1599,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
|
||||
if (resolved_id) {
|
||||
if (path_is_absolute(resolved_id)) {
|
||||
i->uid_path = TAKE_PTR(resolved_id);
|
||||
|
||||
path_kill_slashes(i->uid_path);
|
||||
path_simplify(i->uid_path, false);
|
||||
} else {
|
||||
_cleanup_free_ char *uid = NULL, *gid = NULL;
|
||||
if (split_pair(resolved_id, ":", &uid, &gid) == 0) {
|
||||
@@ -1651,8 +1650,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
|
||||
if (resolved_id) {
|
||||
if (path_is_absolute(resolved_id)) {
|
||||
i->gid_path = TAKE_PTR(resolved_id);
|
||||
|
||||
path_kill_slashes(i->gid_path);
|
||||
path_simplify(i->gid_path, false);
|
||||
} else {
|
||||
r = parse_gid(resolved_id, &i->gid);
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user