From 71af1158ec792a050d8591937906d6609067e599 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Sun, 15 Nov 2015 20:44:13 +0000 Subject: [PATCH] sprintflags: skip zero flags Tweak sprintflags behaviour to match printflags. * util.c (sprintflags): Skip zero flags unless the value passed to sprintflags is also zero. --- util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util.c b/util.c index 5f1f733e..68e82593 100644 --- a/util.c +++ b/util.c @@ -326,8 +326,13 @@ sprintflags(const char *prefix, const struct xlat *xlat, int flags) outptr = stpcpy(outstr, prefix); + if (flags == 0 && xlat->val == 0 && xlat->str) { + strcpy(outptr, xlat->str); + return outstr; + } + for (; xlat->str; xlat++) { - if ((flags & xlat->val) == xlat->val) { + if (xlat->val && (flags & xlat->val) == xlat->val) { if (found) *outptr++ = '|'; outptr = stpcpy(outptr, xlat->str); -- 2.40.0