aboutsummaryrefslogtreecommitdiff
path: root/tools/lib/vsprintf.c
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2019-07-08 13:06:57 -0300
committerArnaldo Carvalho de Melo <acme@redhat.com>2019-07-08 13:06:57 -0300
commite3b22a65348ab54261a98b6bc90ecf8977ff8ebf (patch)
tree81c517d6f0e5585be7af5ffa1a4d4136b1f4a9c6 /tools/lib/vsprintf.c
parent05c78468a60f2fd961cd0a0c01c27f288bf81204 (diff)
parent552a031ba12a4236be107a5b082a399237758a5d (diff)
Merge remote-tracking branch 'tip/perf/core' into perf/urgent
To pick up fixes. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/vsprintf.c')
-rw-r--r--tools/lib/vsprintf.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/tools/lib/vsprintf.c b/tools/lib/vsprintf.c
index e08ee147eab4..8780b4cdab21 100644
--- a/tools/lib/vsprintf.c
+++ b/tools/lib/vsprintf.c
@@ -23,3 +23,22 @@ int scnprintf(char * buf, size_t size, const char * fmt, ...)
return (i >= ssize) ? (ssize - 1) : i;
}
+
+int scnprintf_pad(char * buf, size_t size, const char * fmt, ...)
+{
+ ssize_t ssize = size;
+ va_list args;
+ int i;
+
+ va_start(args, fmt);
+ i = vscnprintf(buf, size, fmt, args);
+ va_end(args);
+
+ if (i < (int) size) {
+ for (; i < (int) size; i++)
+ buf[i] = ' ';
+ buf[i] = 0x0;
+ }
+
+ return (i >= ssize) ? (ssize - 1) : i;
+}