summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/column.c
diff options
context:
space:
mode:
authorOndrej Oprala2014-03-24 13:40:05 +0100
committerKarel Zak2014-04-03 12:29:17 +0200
commit35958d0c61cff969506a4ab1a15e1e28c7a60f77 (patch)
tree0646510949b0b4f4a3b058a2092f39ae18a812a7 /libsmartcols/src/column.c
parentlibsmartcols: separate flags, add getters/setters (diff)
downloadkernel-qcow2-util-linux-35958d0c61cff969506a4ab1a15e1e28c7a60f77.tar.gz
kernel-qcow2-util-linux-35958d0c61cff969506a4ab1a15e1e28c7a60f77.tar.xz
kernel-qcow2-util-linux-35958d0c61cff969506a4ab1a15e1e28c7a60f77.zip
libsmartcols: colors may now be specified as human-readable strings
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Diffstat (limited to 'libsmartcols/src/column.c')
-rw-r--r--libsmartcols/src/column.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libsmartcols/src/column.c b/libsmartcols/src/column.c
index 5fad5319f..29eb63666 100644
--- a/libsmartcols/src/column.c
+++ b/libsmartcols/src/column.c
@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <ctype.h>
#include "smartcolsP.h"
@@ -118,6 +119,12 @@ int scols_column_set_color(struct libscols_column *cl, const char *color)
if (!cl)
return -EINVAL;
if (color) {
+ if (isalnum(*color)) {
+ color = colorscheme_from_string(color);
+
+ if (!color)
+ return -EINVAL;
+ }
p = strdup(color);
if (!p)
return -ENOMEM;