unit-name: fix detection of unit templates/instances

We need to check for the last dot, not the first one in a unit name, for
the suffix. Correct that.

(cherry picked from commit 6ef9eeed61)
This commit is contained in:
Lennart Poettering
2014-06-17 16:53:11 -04:00
committed by Zbigniew Jędrzejewski-Szmek
parent 4f0b9b4334
commit fe2be3dd40
+12 -4
View File
@@ -337,7 +337,7 @@ char *unit_name_path_unescape(const char *f) {
}
bool unit_name_is_template(const char *n) {
const char *p;
const char *p, *e;
assert(n);
@@ -345,11 +345,15 @@ bool unit_name_is_template(const char *n) {
if (!p)
return false;
return p[1] == '.';
e = strrchr(p+1, '.');
if (!e)
return false;
return e == p + 1;
}
bool unit_name_is_instance(const char *n) {
const char *p;
const char *p, *e;
assert(n);
@@ -357,7 +361,11 @@ bool unit_name_is_instance(const char *n) {
if (!p)
return false;
return p[1] != '.';
e = strrchr(p+1, '.');
if (!e)
return false;
return e > p + 1;
}
char *unit_name_replace_instance(const char *f, const char *i) {