commit eb46c0d97b9e80616b2f9827ea77738cc2b96fc4
parent f79ba06cb4142991dcf12ed6fccdf5c1485457c9
Author: Drew DeVault <sir@cmpwn.com>
Date: Sun, 22 Nov 2020 11:43:44 -0500
identifier: fix unparse with multiple namespaces
Diffstat:
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/identifier.c b/src/identifier.c
@@ -49,13 +49,14 @@ identifier_unparse_static(const struct identifier *ident, char *buf, size_t len)
assert(len < INT_MAX);
if (ident->ns) {
int prefix = identifier_unparse_static(ident->ns, buf, len);
- int n = snprintf(&buf[prefix], len - prefix, "::%s", ident->name);
+ int n = snprintf(&buf[prefix], len - prefix,
+ "::%s", ident->name);
if (n >= (int)len) {
buf[len - 1] = '\0';
}
- return n;
+ return prefix + n;
}
- int n = snprintf(buf, len, ident->name);
+ int n = snprintf(buf, len, "%s", ident->name);
if (n >= (int)len) {
buf[len - 1] = '\0';
}