mirror of
https://github.com/AuxXxilium/eudev.git
synced 2025-02-25 21:29:54 +07:00
unit-name: kill redundant slashes in unit_name_from_path()
This commit is contained in:
parent
2a1a539789
commit
5ffceb2fea
19
unit-name.c
19
unit-name.c
@ -373,16 +373,27 @@ char *unit_name_template(const char *f) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
char *unit_name_from_path(const char *path, const char *suffix) {
|
char *unit_name_from_path(const char *path, const char *suffix) {
|
||||||
|
char *p, *r;
|
||||||
|
|
||||||
assert(path);
|
assert(path);
|
||||||
assert(suffix);
|
assert(suffix);
|
||||||
|
|
||||||
if (path[0] == '/')
|
if (!(p = strdup(path)))
|
||||||
path++;
|
return NULL;
|
||||||
|
|
||||||
if (path[0] == 0)
|
path_kill_slashes(p);
|
||||||
|
|
||||||
|
path = p[0] == '/' ? p + 1 : p;
|
||||||
|
|
||||||
|
if (path[0] == 0) {
|
||||||
|
free(p);
|
||||||
return strappend("-", suffix);
|
return strappend("-", suffix);
|
||||||
|
}
|
||||||
|
|
||||||
return unit_name_build_escape(path, NULL, suffix);
|
r = unit_name_build_escape(path, NULL, suffix);
|
||||||
|
free(p);
|
||||||
|
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *unit_name_to_path(const char *name) {
|
char *unit_name_to_path(const char *name) {
|
||||||
|
Loading…
Reference in New Issue
Block a user