summaryrefslogtreecommitdiffstats
path: root/libsmartcols
diff options
context:
space:
mode:
authorKarel Zak2016-09-27 14:16:18 +0200
committerKarel Zak2016-09-27 14:16:18 +0200
commit68a7f92b94431b28aa345ab30214c3490dcc10bd (patch)
tree2618940fd0e7ae0fe69518bde09cf601db7324ae /libsmartcols
parentdocs: some random fixes (diff)
downloadkernel-qcow2-util-linux-68a7f92b94431b28aa345ab30214c3490dcc10bd.tar.gz
kernel-qcow2-util-linux-68a7f92b94431b28aa345ab30214c3490dcc10bd.tar.xz
kernel-qcow2-util-linux-68a7f92b94431b28aa345ab30214c3490dcc10bd.zip
libsmartcols: custom wrap fixes
Reported-by: Igor Gnatenko <i.gnatenko.brain@gmail.com Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libsmartcols')
-rw-r--r--libsmartcols/src/column.c10
-rw-r--r--libsmartcols/src/libsmartcols.h.in2
-rw-r--r--libsmartcols/src/smartcolsP.h2
3 files changed, 6 insertions, 8 deletions
diff --git a/libsmartcols/src/column.c b/libsmartcols/src/column.c
index 2dee2c02a..6f74f76fb 100644
--- a/libsmartcols/src/column.c
+++ b/libsmartcols/src/column.c
@@ -72,6 +72,7 @@ void scols_unref_column(struct libscols_column *cl)
list_del(&cl->cl_columns);
scols_reset_cell(&cl->header);
free(cl->color);
+ free(cl->safechars);
free(cl->pending_data_buf);
free(cl);
}
@@ -176,7 +177,7 @@ int scols_column_set_flags(struct libscols_column *cl, int flags)
*
* Returns: pointer to the table where columns is used
*/
-struct libscols_table *scols_column_get_table(struct libscols_column *cl)
+struct libscols_table *scols_column_get_table(const struct libscols_column *cl)
{
return cl->table;
}
@@ -246,7 +247,7 @@ const char *scols_column_get_color(const struct libscols_column *cl)
* @data: string
* @userdata: callback private data
*
- * This is build-in function for scols_column_set_wrapfunc(). This function
+ * This is built-in function for scols_column_set_wrapfunc(). This function
* terminates the current chunk by \0 and returns pointer to the begin of
* the next chunk. The chunks are based on \n.
*
@@ -379,10 +380,7 @@ int scols_column_set_wrapfunc(struct libscols_column *cl,
*/
int scols_column_set_safechars(struct libscols_column *cl, const char *safe)
{
- if (!cl)
- return -EINVAL;
- cl->safechars = safe;
- return 0;
+ return strdup_to_struct_member(cl, safechars, safe);
}
/**
diff --git a/libsmartcols/src/libsmartcols.h.in b/libsmartcols/src/libsmartcols.h.in
index 94b1aada2..d7f1da6b1 100644
--- a/libsmartcols/src/libsmartcols.h.in
+++ b/libsmartcols/src/libsmartcols.h.in
@@ -161,7 +161,7 @@ extern double scols_column_get_whint(const struct libscols_column *cl);
extern struct libscols_cell *scols_column_get_header(struct libscols_column *cl);
extern int scols_column_set_color(struct libscols_column *cl, const char *color);
extern const char *scols_column_get_color(const struct libscols_column *cl);
-extern struct libscols_table *scols_column_get_table(struct libscols_column *cl);
+extern struct libscols_table *scols_column_get_table(const struct libscols_column *cl);
extern int scols_column_set_cmpfunc(struct libscols_column *cl,
int (*cmp)(struct libscols_cell *a,
diff --git a/libsmartcols/src/smartcolsP.h b/libsmartcols/src/smartcolsP.h
index 2f29c9f63..2a76048e1 100644
--- a/libsmartcols/src/smartcolsP.h
+++ b/libsmartcols/src/smartcolsP.h
@@ -85,6 +85,7 @@ struct libscols_column {
int flags;
int is_extreme;
char *color; /* default column color */
+ char *safechars; /* do not encode this bytes */
char *pending_data;
size_t pending_data_sz;
@@ -101,7 +102,6 @@ struct libscols_column {
char *, void *);
void *wrapfunc_data;
- const char *safechars; /* do not encode this bytes */
struct libscols_cell header;
struct list_head cl_columns;