+/* Copies buffer SRC, of SRC_SIZE bytes, to DST, of DST_SIZE bytes.
+ DST is truncated to DST_SIZE bytes or padded on the left with
+ spaces as needed. */
+void
+buf_copy_lpad (char *dst, size_t dst_size,
+ const char *src, size_t src_size)
+{
+ if (src_size >= dst_size)
+ memmove (dst, src, dst_size);
+ else
+ {
+ memset (dst, ' ', dst_size - src_size);
+ memmove (&dst[dst_size - src_size], src, src_size);
+ }
+}
+