summaryrefslogtreecommitdiffstats
path: root/libsmartcols/src/cell.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/cell.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/cell.c')
-rw-r--r--libsmartcols/src/cell.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libsmartcols/src/cell.c b/libsmartcols/src/cell.c
index 5e3ea6081..fb523f013 100644
--- a/libsmartcols/src/cell.c
+++ b/libsmartcols/src/cell.c
@@ -12,6 +12,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <ctype.h>
#include "smartcolsP.h"
@@ -85,6 +86,12 @@ int scols_cell_set_color(struct libscols_cell *ce, const char *color)
if (!ce)
return -EINVAL;
if (color) {
+ if (isalnum(*color)) {
+ color = colorscheme_from_string(color);
+
+ if (!color)
+ return -EINVAL;
+ }
p = strdup(color);
if (!p)
return -ENOMEM;