summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/symbols.c
diff options
context:
space:
mode:
authorKarel Zak2016-01-22 16:51:59 +0100
committerKarel Zak2016-01-22 16:51:59 +0100
commit57867795aa7dead56a7339a13f08ea1f3a5de615 (patch)
treea1b1f247bcb0c70cc135efd98c43c28b0b0234f5 /libsmartcols/src/symbols.c
parentlibsmartcols: add title to the test application (diff)
downloadkernel-qcow2-util-linux-57867795aa7dead56a7339a13f08ea1f3a5de615.tar.gz
kernel-qcow2-util-linux-57867795aa7dead56a7339a13f08ea1f3a5de615.tar.xz
kernel-qcow2-util-linux-57867795aa7dead56a7339a13f08ea1f3a5de615.zip
libsmartcols: support multibyte titles, rename wrap to padding
- let's support multibyte table titles - use lib/mbalign.c to align the title - rename title_wrap to title_padding (we already use "wrap" on another places for another things) Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols/src/symbols.c')
-rw-r--r--libsmartcols/src/symbols.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/libsmartcols/src/symbols.c b/libsmartcols/src/symbols.c
index dfe2ba7b6..cdf06ab66 100644
--- a/libsmartcols/src/symbols.c
+++ b/libsmartcols/src/symbols.c
@@ -62,7 +62,7 @@ void scols_unref_symbols(struct libscols_symbols *sy)
free(sy->branch);
free(sy->vert);
free(sy->right);
- free(sy->title_wrap);
+ free(sy->title_padding);
free(sy);
}
}
@@ -143,13 +143,16 @@ int scols_symbols_set_right(struct libscols_symbols *sb, const char *str)
}
/**
- * scols_symbols_set_title_wrap:
+ * scols_symbols_set_title_padding:
* @sb: a pointer to a struct libscols_symbols instance
* @str: a string which will represent the symbols which wraps title output
*
+ * The current implemetation uses only the first byte from the padding string.
+ * A multibyte chars are not supported yet.
+ *
* Returns: 0, a negative value in case of an error.
*/
-int scols_symbols_set_title_wrap(struct libscols_symbols *sb, const char *str)
+int scols_symbols_set_title_padding(struct libscols_symbols *sb, const char *str)
{
char *p = NULL;
@@ -162,8 +165,8 @@ int scols_symbols_set_title_wrap(struct libscols_symbols *sb, const char *str)
if (!p)
return -ENOMEM;
}
- free(sb->title_wrap);
- sb->title_wrap = p;
+ free(sb->title_padding);
+ sb->title_padding = p;
return 0;
}
@@ -192,7 +195,7 @@ struct libscols_symbols *scols_copy_symbols(const struct libscols_symbols *sb)
if (!rc)
rc = scols_symbols_set_right(ret, sb->right);
if (!rc)
- rc = scols_symbols_set_title_wrap(ret, sb->title_wrap);
+ rc = scols_symbols_set_title_padding(ret, sb->title_padding);
if (!rc)
return ret;