]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: support LIBSMARTCOLS_DEBUG_PADDING=on
authorKarel Zak <kzak@redhat.com>
Wed, 7 Sep 2016 10:25:06 +0000 (12:25 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 7 Sep 2016 10:25:06 +0000 (12:25 +0200)
This env.variable forces libsmartcols to use visible padding chars.
The standard debug has to be enabled (to minimize overhead for
non-debug execution).

For example:

 $ LIBSMARTCOLS_DEBUG=all LIBSMARTCOLS_DEBUG_PADDING=on findmnt 2> ~/log

Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/cfdisk.8
disk-utils/fdisk.8
libsmartcols/src/smartcolsP.h
libsmartcols/src/table.c
libsmartcols/src/table_print.c
misc-utils/findmnt.8
misc-utils/lsblk.8

index 68cec94921f82ac2340ffa6412f26710a6392e9d..6204bdc4f40f7bb189e75f4d342009b59f5f8b9c 100644 (file)
@@ -184,6 +184,8 @@ enables libfdisk debug output.
 enables libblkid debug output.
 .IP LIBSMARTCOLS_DEBUG=all
 enables libsmartcols debug output.
+.IP LIBSMARTCOLS_DEBUG_PADDING=on
+use visible padding characters. Requires enabled LIBSMARTCOLS_DEBUG.
 
 .SH "SEE ALSO"
 .BR fdisk (8),
index 5d644d8d696897e8b1b854594f31addf9698d9a2..70e88e36af55f2eab4000ddd734e2d135d05243a 100644 (file)
@@ -354,6 +354,8 @@ enables libfdisk debug output.
 enables libblkid debug output.
 .IP LIBSMARTCOLS_DEBUG=all
 enables libsmartcols debug output.
+.IP LIBSMARTCOLS_DEBUG_PADDING=on
+use visible padding characters. Requires enabled LIBSMARTCOLS_DEBUG.
 
 .SH "SEE ALSO"
 .BR cfdisk (8),
index c1bb1e07f76a17fc09910a4dae4eec398e89a81a..01b132752ce83a2ccf867530934f252c6cedfb7f 100644 (file)
@@ -157,6 +157,7 @@ struct libscols_table {
        unsigned int    ascii           :1,     /* don't use unicode */
                        colors_wanted   :1,     /* enable colors */
                        is_term         :1,     /* isatty() */
+                       padding_debug   :1,     /* output visible padding chars */
                        maxout          :1,     /* maximize output */
                        header_printed  :1,     /* header already printed */
                        no_headings     :1,     /* don't print header */
index dc3a3016c7e0e7cb1f1ce1a86602ddb257b27c4c..10320f0be0ec9469a33ae7fafc62034499369162 100644 (file)
                list_entry_is_last(&(_cl)->cl_columns, &(_tb)->tb_columns)
 
 
+static void check_padding_debug(struct libscols_table *tb)
+{
+       const char *str;
+
+       assert(libsmartcols_debug_mask);        /* debug has to be enabled! */
+
+       str = getenv("LIBSMARTCOLS_DEBUG_PADDING");
+       if (!str || (strcmp(str, "on") != 0 && strcmp(str, "1") != 0))
+               return;
+
+       DBG(INIT, ul_debugobj(tb, "padding debug: ENABLE"));
+       tb->padding_debug = 1;
+}
+
 /**
  * scols_new_table:
  *
@@ -58,6 +72,8 @@ struct libscols_table *scols_new_table(void)
        INIT_LIST_HEAD(&tb->tb_columns);
 
        DBG(TAB, ul_debugobj(tb, "alloc"));
+       ON_DBG(INIT, check_padding_debug(tb));
+
        return tb;
 }
 
index 910a9137a6000e064bcd90b71610b0997bbaad85..bdac0b296d6a3e13678c096c465304b34bf8cf62 100644 (file)
  * fallback to be more robust and backwardly compatible.
  */
 #define titlepadding_symbol(tb)        ((tb)->symbols->title_padding ? (tb)->symbols->title_padding : " ")
-#define cellpadding_symbol(tb)  ((tb)->symbols->cell_padding ? (tb)->symbols->cell_padding: " ")
 #define branch_symbol(tb)      ((tb)->symbols->branch ? (tb)->symbols->branch : "|-")
 #define vertical_symbol(tb)    ((tb)->symbols->vert ? (tb)->symbols->vert : "|")
 #define right_symbol(tb)       ((tb)->symbols->right ? (tb)->symbols->right : "-")
 
+#define cellpadding_symbol(tb)  ((tb)->padding_debug ? "." : \
+                                ((tb)->symbols->cell_padding ? (tb)->symbols->cell_padding: " "))
+
 
 /* This is private struct to work with output data */
 struct libscols_buffer {
index 3f09b1900562c2a201940751403126dd717b9565..fd26f5e5c0b97ac14bc21d2902a5993a10dcaf88 100644 (file)
@@ -267,6 +267,8 @@ overrides the default location of the mtab file
 enables libmount debug output
 .IP LIBSMARTCOLS_DEBUG=all
 enables libsmartcols debug output
+.IP LIBSMARTCOLS_DEBUG_PADDING=on
+use visible padding characters. Requires enabled LIBSMARTCOLS_DEBUG.
 .SH AUTHORS
 .nf
 Karel Zak <kzak@redhat.com>
index 3e74e37ce2376d0eced0519247a57bfff109cfbd..d82d232b3bfecc518e0df1ae4fbe7acfab288d43 100644 (file)
@@ -161,6 +161,8 @@ enables libblkid debug output.
 enables libmount debug output.
 .IP LIBSMARTCOLS_DEBUG=all
 enables libsmartcols debug output.
+.IP LIBSMARTCOLS_DEBUG_PADDING=on
+use visible padding characters. Requires enabled LIBSMARTCOLS_DEBUG.
 .SH SEE ALSO
 .BR findmnt (8),
 .BR blkid (8),