summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/special-vars.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/core/special-vars.c b/src/core/special-vars.c
index f254c200..e131b0ed 100644
--- a/src/core/special-vars.c
+++ b/src/core/special-vars.c
@@ -337,11 +337,14 @@ char *get_alignment(const char *text, int align, int flags, char pad)
/* add pad characters */
if (flags & ALIGN_PAD) {
- while (string_width(str->str, policy) < align) {
+ int pad_len = align - string_width(str->str, policy);
+ if (pad_len > 0) {
+ char *pad_full = g_strnfill(pad_len, pad);
if (flags & ALIGN_RIGHT)
- g_string_prepend_c(str, pad);
+ g_string_prepend(str, pad_full);
else
- g_string_append_c(str, pad);
+ g_string_append(str, pad_full);
+ g_free(pad_full);
}
}