From f2c543b4ccad3b9f8871d952cddf66b3b438595b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 2 Jul 2021 22:49:35 +0200 Subject: Merging upstream version 1.14. Signed-off-by: Daniel Baumann --- plugins/wdc/wdc-utils.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'plugins/wdc/wdc-utils.c') diff --git a/plugins/wdc/wdc-utils.c b/plugins/wdc/wdc-utils.c index 80d9955..2740181 100644 --- a/plugins/wdc/wdc-utils.c +++ b/plugins/wdc/wdc-utils.c @@ -144,3 +144,18 @@ int wdc_UtilsStrCompare(char *pcSrc, char *pcDst) return *pcSrc - *pcDst; } +void wdc_StrFormat(char *formatter, size_t fmt_sz, char *tofmt, size_t tofmtsz) +{ + + fmt_sz = snprintf(formatter,fmt_sz, "%-*.*s", + (int)tofmtsz, (int)tofmtsz, tofmt); + /* trim() the obnoxious trailing white lines */ + while (fmt_sz) { + if (formatter[fmt_sz - 1] != ' ' && formatter[fmt_sz - 1] != '\0') { + formatter[fmt_sz] = '\0'; + break; + } + fmt_sz--; + } +} + -- cgit v1.2.3