chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
journal: systemd v38 fails to build on big-endians
[elogind.git]
/
src
/
unit-name.c
diff --git
a/src/unit-name.c
b/src/unit-name.c
index dbaa4a7b12c3acdf5b02b323e236477e0336d8cb..1cbb804561419d10b1c9d121e7bc2aa35913a101 100644
(file)
--- a/
src/unit-name.c
+++ b/
src/unit-name.c
@@
-167,8
+167,6
@@
char *unit_name_change_suffix(const char *n, const char *suffix) {
}
char *unit_name_build(const char *prefix, const char *instance, const char *suffix) {
}
char *unit_name_build(const char *prefix, const char *instance, const char *suffix) {
- char *r;
-
assert(prefix);
assert(unit_prefix_is_valid(prefix));
assert(!instance || unit_instance_is_valid(instance));
assert(prefix);
assert(unit_prefix_is_valid(prefix));
assert(!instance || unit_instance_is_valid(instance));
@@
-177,10
+175,7
@@
char *unit_name_build(const char *prefix, const char *instance, const char *suff
if (!instance)
return strappend(prefix, suffix);
if (!instance)
return strappend(prefix, suffix);
- if (asprintf(&r, "%s@%s%s", prefix, instance, suffix) < 0)
- return NULL;
-
- return r;
+ return join(prefix, "@", instance, suffix, NULL);
}
static char* do_escape(const char *f, char *t) {
}
static char* do_escape(const char *f, char *t) {
@@
-213,7
+208,7
@@
char *unit_name_build_escape(const char *prefix, const char *instance, const cha
* suffix and makes a nice string suitable as unit name of it,
* escaping all weird chars on the way.
*
* suffix and makes a nice string suitable as unit name of it,
* escaping all weird chars on the way.
*
- * / becomes ., and all chars not allowe
e
d in a unit name get
+ * / becomes ., and all chars not allowed in a unit name get
* escaped as \xFF, including \ and ., of course. This
* escaping is hence reversible.
*
* escaped as \xFF, including \ and ., of course. This
* escaping is hence reversible.
*
@@
-272,13
+267,14
@@
char *unit_name_unescape(const char *f) {
else if (*f == '\\') {
int a, b;
else if (*f == '\\') {
int a, b;
- if ((a = unhexchar(f[1])) < 0 ||
- (b = unhexchar(f[2])) < 0) {
+ if (f[1] != 'x' ||
+ (a = unhexchar(f[2])) < 0 ||
+ (b = unhexchar(f[3])) < 0) {
/* Invalid escape code, let's take it literal then */
*(t++) = '\\';
} else {
*(t++) = (char) ((a << 4) | b);
/* Invalid escape code, let's take it literal then */
*(t++) = '\\';
} else {
*(t++) = (char) ((a << 4) | b);
- f +=
2
;
+ f +=
3
;
}
} else
*(t++) = *f;
}
} else
*(t++) = *f;
@@
-427,3
+423,26
@@
char *unit_name_to_path(const char *name) {
return e;
}
return e;
}
+
+char *unit_name_path_unescape(const char *f) {
+ char *e;
+
+ assert(f);
+
+ if (!(e = unit_name_unescape(f)))
+ return NULL;
+
+ if (e[0] != '/') {
+ char *w;
+
+ w = strappend("/", e);
+ free(e);
+
+ if (!w)
+ return NULL;
+
+ e = w;
+ }
+
+ return e;
+}