]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
Use libsmartcols in libfdisk and cfdisk
authorOndrej Oprala <ooprala@redhat.com>
Thu, 27 Mar 2014 13:58:51 +0000 (14:58 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 3 Apr 2014 10:29:18 +0000 (12:29 +0200)
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
12 files changed:
Makefile.am
configure.ac
disk-utils/Makemodule.am
disk-utils/cfdisk.c
libfdisk/src/Makemodule.am
libfdisk/src/bsd.c
libfdisk/src/dos.c
libfdisk/src/fdiskP.h
libfdisk/src/gpt.c
libfdisk/src/sgi.c
libfdisk/src/sun.c
libfdisk/src/table.c

index 2c19283d7dd29f4550235f974fbd783f722cfcb8..a20e65da3eb77f397297137236311498d08b3a86 100644 (file)
@@ -79,8 +79,8 @@ include lib/Makemodule.am
 include libuuid/Makemodule.am
 include libblkid/Makemodule.am
 include libmount/Makemodule.am
-include libfdisk/Makemodule.am
 include libsmartcols/Makemodule.am
+include libfdisk/Makemodule.am
 
 include schedutils/Makemodule.am
 include text-utils/Makemodule.am
index f1b4cae50d6e5725640efc79f3da52829441135d..3d2c5d064d325dd03098be20a2e6469b619f6732 100644 (file)
@@ -817,10 +817,11 @@ AC_DEFINE_UNQUOTED([LIBSMARTCOLS_VERSION], ["$LIBSMARTCOLS_VERSION"], [libsmartc
 
 
 dnl
-dnl libfdisk is enabled all time if possible
+dnl libfdisk is enabled at all times if possible
 dnl
 UL_BUILD_INIT([libfdisk], [check])
 UL_REQUIRES_BUILD([libfdisk], [libuuid])
+UL_REQUIRES_BUILD([libfdisk], [libsmartcols])
 AM_CONDITIONAL([BUILD_LIBFDISK], [test "x$build_libfdisk" = xyes])
 
 UL_BUILD_INIT([fdisk], [check])
index dd9143931649ebf44f3b8365df8b453654e6e272..8780df6444ffa1331beb3832ac078e2e3311f2d1 100644 (file)
@@ -176,6 +176,11 @@ cfdisk_CFLAGS += -I$(ul_libblkid_incdir)
 cfdisk_LDADD += libblkid.la
 endif
 
+if BUILD_LIBSMARTCOLS
+cfdisk_CFLAGS += -I$(ul_libsmartcols_incdir)
+cfdisk_LDADD += libsmartcols.la
+endif
+
 if HAVE_SLANG
 cfdisk_LDADD += -lslang
 else
index bc8290d8b7b301f7e3aee88c35a65fb47b658da7..030cc19bf22bcbd2c0772393a140f41dbb4bdbd7 100644 (file)
@@ -4,6 +4,7 @@
 #include <signal.h>
 #include <ctype.h>
 #include <getopt.h>
+#include <libsmartcols.h>
 
 #ifdef HAVE_SLANG_H
 # include <slang.h>
@@ -166,11 +167,12 @@ static char *table_to_string(struct cfdisk *cf, struct fdisk_table *tb)
        struct fdisk_partition *pa;
        struct fdisk_label *lb;
        struct fdisk_iter *itr = NULL;
-       struct tt *tt = NULL;
+       struct libscols_table *table = NULL;
+       struct libscols_iter *s_itr = NULL;
        char *res = NULL;
        size_t i;
        int tree = 0;
-       struct tt_line *ln, *ln_cont = NULL;
+       struct libscols_line *ln, *ln_cont = NULL;
 
        DBG(FRONTEND, ul_debug("table: convert to string"));
 
@@ -190,23 +192,26 @@ static char *table_to_string(struct cfdisk *cf, struct fdisk_table *tb)
        while (fdisk_table_next_partition(tb, itr, &pa) == 0) {
                if (fdisk_partition_is_nested(pa)) {
                        DBG(FRONTEND, ul_debug("table: nested detected, using tree"));
-                       tree = TT_FL_TREE;
+                       tree = SCOLS_FL_TREE;
                        break;
                }
        }
 
-       tt = tt_new_table(TT_FL_FREEDATA | TT_FL_MAX | tree);
-       if (!tt)
+       table = scols_new_table(NULL);
+       if (!table)
                goto done;
+       scols_table_set_max(table, 1);
+       scols_table_set_tree(table, tree);
 
        /* headers */
        for (i = 0; i < cf->ncols; i++) {
                col = fdisk_label_get_column(lb, cf->cols[i]);
                if (col) {
-                       int fl = col->tt_flags;
+                       int fl = col->scols_flags;
                        if (tree && col->id == FDISK_COL_DEVICE)
-                               fl |= TT_FL_TREE;
-                       tt_define_column(tt, col->name, col->width, fl);
+                               fl |= SCOLS_FL_TREE;
+                       if (!scols_table_new_column(table, col->name, col->width, fl))
+                               goto done;
                }
        }
 
@@ -214,9 +219,9 @@ static char *table_to_string(struct cfdisk *cf, struct fdisk_table *tb)
        fdisk_reset_iter(itr, FDISK_ITER_FORWARD);
 
        while (fdisk_table_next_partition(tb, itr, &pa) == 0) {
-               struct tt_line *parent = fdisk_partition_is_nested(pa) ? ln_cont : NULL;
+               struct libscols_line *parent = fdisk_partition_is_nested(pa) ? ln_cont : NULL;
 
-               ln = tt_add_line(tt, parent);
+               ln = scols_table_new_line(table, parent);
                if (!ln)
                        goto done;
                for (i = 0; i < cf->ncols; i++) {
@@ -226,22 +231,22 @@ static char *table_to_string(struct cfdisk *cf, struct fdisk_table *tb)
                                continue;
                        if (fdisk_partition_to_string(pa, cf->cxt, col->id, &cdata))
                                continue;
-                       tt_line_set_data(ln, i, cdata);
+                       scols_line_set_data(ln, i, cdata);
                }
                if (tree && fdisk_partition_is_container(pa))
                        ln_cont = ln;
 
-               tt_line_set_userdata(ln, (void *) pa);
+               scols_line_set_userdata(ln, (void *) pa);
                fdisk_ref_partition(pa);
        }
 
-       if (tt_is_empty(tt))
+       if (scols_table_is_empty(table))
                goto done;
 
-       tt_set_termreduce(tt, ARROW_CURSOR_WIDTH);
-       tt_print_table_to_string(tt, &res);
+       scols_table_reduce_termwidth(table, ARROW_CURSOR_WIDTH);
+       scols_print_table_to_string(table, &res);
 
-       /* tt_* code might to reorder lines, let's reorder @tb according to the
+       /* scols_* code might reorder lines, let's reorder @tb according to the
         * final output (it's no problem because partitions are addressed by
         * parno stored within struct fdisk_partition)  */
 
@@ -251,15 +256,19 @@ static char *table_to_string(struct cfdisk *cf, struct fdisk_table *tb)
                fdisk_table_remove_partition(tb, pa);
 
        /* add all in the right order */
-       i = 0;
-       while (tt_get_output_line(tt, i++, &ln) == 0) {
-               struct fdisk_partition *pa = tt_line_get_userdata(ln);
+       s_itr = scols_new_iter(SCOLS_ITER_FORWARD);
+       if (!s_itr)
+               goto done;
+
+       while (scols_table_next_line(table, s_itr, &ln) == 0) {
+               struct fdisk_partition *pa = scols_line_get_userdata(ln);
 
                fdisk_table_add_partition(tb, pa);
                fdisk_unref_partition(pa);
        }
 done:
-       tt_free_table(tt);
+       scols_unref_table(table);
+       scols_free_iter(s_itr);
        fdisk_free_iter(itr);
 
        return res;
index d8cbffbe37df3798f89c99c0d6d6c953e5a182fc..99bddb2dad191c589abf03a65f12d85bbeabbace 100644 (file)
@@ -49,6 +49,12 @@ libfdisk_la_DEPENDENCIES += libuuid.la
 libfdisk_la_CFLAGS += -I$(ul_libuuid_incdir)
 endif
 
+if BUILD_LIBSMARTCOLS
+libfdisk_la_LIBADD += libsmartcols.la
+libfdisk_la_DEPENDENCIES += libsmartcols.la
+libfdisk_la_CFLAGS += -I$(ul_libsmartcols_incdir)
+endif
+
 check_PROGRAMS += \
        test_fdisk_ask \
        test_fdisk_utils
@@ -65,6 +71,10 @@ if BUILD_LIBUUID
 libfdisk_tests_ldflags += libuuid.la
 endif
 
+if BUILD_LIBSMARTCOLS
+libfdisk_tests_ldflags += libsmartcols.la
+endif
+
 test_fdisk_ask_SOURCES = libfdisk/src/ask.c
 test_fdisk_ask_CFLAGS = $(libfdisk_tests_cflags)
 test_fdisk_ask_LDFLAGS = $(libfdisk_tests_ldflags)
index 4ece79fb21ecf3d8972ba76d35083d55353539c6..a81afd2c3c8941edb0f069446e0ffc30d11cc777 100644 (file)
@@ -15,6 +15,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <sys/param.h>
+#include <libsmartcols.h>
 
 #include "nls.h"
 #include "blkdev.h"
@@ -879,15 +880,15 @@ static const struct fdisk_label_operations bsd_operations =
 static const struct fdisk_column bsd_columns[] =
 {
        { FDISK_COL_DEVICE,     N_("Slice"),      1,    0 },
-       { FDISK_COL_START,      N_("Start"),      5,    TT_FL_RIGHT },
-       { FDISK_COL_END,        N_("End"),        5,    TT_FL_RIGHT },
-       { FDISK_COL_SECTORS,    N_("Sectors"),    5,    TT_FL_RIGHT },
-       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    TT_FL_RIGHT },
-       { FDISK_COL_SIZE,       N_("Size"),       5,    TT_FL_RIGHT },
+       { FDISK_COL_START,      N_("Start"),      5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_END,        N_("End"),        5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_SECTORS,    N_("Sectors"),    5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_SIZE,       N_("Size"),       5,    SCOLS_FL_RIGHT },
        { FDISK_COL_TYPE,       N_("Type"),       8,    0 },
-       { FDISK_COL_FSIZE,      N_("Fsize"),      5,    TT_FL_RIGHT },
-       { FDISK_COL_BSIZE,      N_("Bsize"),      5,    TT_FL_RIGHT },
-       { FDISK_COL_CPG,        N_("Cpg"),        5,    TT_FL_RIGHT }
+       { FDISK_COL_FSIZE,      N_("Fsize"),      5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_BSIZE,      N_("Bsize"),      5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_CPG,        N_("Cpg"),        5,    SCOLS_FL_RIGHT }
 };
 
 /*
index 612f562a6474fc3dfa0bf6d3a98680a7643c0c33..b1b23350fda0e24cf017632fcce84eb290a91bc4 100644 (file)
@@ -15,6 +15,7 @@
 #include "fdiskP.h"
 
 #include <ctype.h>
+#include <libsmartcols.h>
 
 #define MAXIMUM_PARTS  60
 #define ACTIVE_FLAG     0x80
@@ -1914,18 +1915,18 @@ static const struct fdisk_column dos_columns[] =
        /* basic */
        { FDISK_COL_DEVICE,     N_("Device"),    10,    0 },
        { FDISK_COL_BOOT,       N_("Boot"),       1,    0 },
-       { FDISK_COL_START,      N_("Start"),      5,    TT_FL_RIGHT },
-       { FDISK_COL_END,        N_("End"),        5,    TT_FL_RIGHT },
-       { FDISK_COL_SECTORS,    N_("Sectors"),    5,    TT_FL_RIGHT },
-       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    TT_FL_RIGHT },
-       { FDISK_COL_SIZE,       N_("Size"),       5,    TT_FL_RIGHT, FDISK_COLFL_EYECANDY },
-       { FDISK_COL_TYPEID,     N_("Id"),         2,    TT_FL_RIGHT },
-       { FDISK_COL_TYPE,       N_("Type"),     0.1,    TT_FL_TRUNC },
+       { FDISK_COL_START,      N_("Start"),      5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_END,        N_("End"),        5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_SECTORS,    N_("Sectors"),    5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_SIZE,       N_("Size"),       5,    SCOLS_FL_RIGHT, FDISK_COLFL_EYECANDY },
+       { FDISK_COL_TYPEID,     N_("Id"),         2,    SCOLS_FL_RIGHT },
+       { FDISK_COL_TYPE,       N_("Type"),     0.1,    SCOLS_FL_TRUNC },
 
        /* expert mode */
-       { FDISK_COL_SADDR,      N_("Start-C/H/S"), 1,   TT_FL_RIGHT, FDISK_COLFL_DETAIL },
-       { FDISK_COL_EADDR,      N_("End-C/H/S"),   1,   TT_FL_RIGHT, FDISK_COLFL_DETAIL },
-       { FDISK_COL_ATTR,       N_("Attrs"),       2,   TT_FL_RIGHT, FDISK_COLFL_DETAIL }
+       { FDISK_COL_SADDR,      N_("Start-C/H/S"), 1,   SCOLS_FL_RIGHT, FDISK_COLFL_DETAIL },
+       { FDISK_COL_EADDR,      N_("End-C/H/S"),   1,   SCOLS_FL_RIGHT, FDISK_COLFL_DETAIL },
+       { FDISK_COL_ATTR,       N_("Attrs"),       2,   SCOLS_FL_RIGHT, FDISK_COLFL_DETAIL }
 
 };
 
index cb3c2b27cdb24c0c10fb0c6ffd712fdea6c556b2..f966d0a68519d6745faece38f21af8b580653224 100644 (file)
 #include <sys/types.h>
 #include <unistd.h>
 
+
 #include "c.h"
 #include "libfdisk.h"
 
 #include "nls.h"               /* temporary before dialog API will be implamented */
 #include "list.h"
-#include "tt.h"
 #include "debug.h"
 #include <stdio.h>
 #include <stdarg.h>
@@ -233,7 +233,7 @@ struct fdisk_column {
        int             id;             /* FDISK_COL_* */
        const char      *name;          /* column header */
        double          width;
-       int             tt_flags;       /* TT_FL_* */
+       int             scols_flags;    /* SCOLS_FL_* */
 
        int             flags;          /* FDISK_COLFL_* */
 };
index 1f5c03b0d195b86284cfc12b7beaf197d2a51377..aba33cd37c366d7b7ff9b2a6f9dd118659237885 100644 (file)
@@ -18,6 +18,7 @@
 #include <errno.h>
 #include <ctype.h>
 #include <uuid.h>
+#include <libsmartcols.h>
 
 #include "fdiskP.h"
 
@@ -2349,16 +2350,16 @@ static const struct fdisk_column gpt_columns[] =
 {
        /* basic */
        { FDISK_COL_DEVICE,     N_("Device"),    10,    0 },
-       { FDISK_COL_START,      N_("Start"),      5,    TT_FL_RIGHT },
-       { FDISK_COL_END,        N_("End"),        5,    TT_FL_RIGHT },
-       { FDISK_COL_SECTORS,    N_("Sectors"),    5,    TT_FL_RIGHT },
-       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    TT_FL_RIGHT },
-       { FDISK_COL_SIZE,       N_("Size"),       5,    TT_FL_RIGHT, FDISK_COLFL_EYECANDY },
-       { FDISK_COL_TYPE,       N_("Type"),     0.1,    TT_FL_TRUNC, FDISK_COLFL_EYECANDY },
+       { FDISK_COL_START,      N_("Start"),      5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_END,        N_("End"),        5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_SECTORS,    N_("Sectors"),    5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_SIZE,       N_("Size"),       5,    SCOLS_FL_RIGHT, FDISK_COLFL_EYECANDY },
+       { FDISK_COL_TYPE,       N_("Type"),     0.1,    SCOLS_FL_TRUNC, FDISK_COLFL_EYECANDY },
        /* expert */
        { FDISK_COL_TYPEID,     N_("Type-UUID"), 36,    0,           FDISK_COLFL_DETAIL },
        { FDISK_COL_UUID,       N_("UUID"),      36,    0,           FDISK_COLFL_DETAIL },
-       { FDISK_COL_NAME,       N_("Name"),     0.2,    TT_FL_TRUNC, FDISK_COLFL_DETAIL },
+       { FDISK_COL_NAME,       N_("Name"),     0.2,    SCOLS_FL_TRUNC, FDISK_COLFL_DETAIL },
        { FDISK_COL_ATTR,       N_("Attrs"),      0,    0,           FDISK_COLFL_DETAIL }
 };
 
index 8204ce9d59fb1f981a5b172e5b22c57e2e2bd6e1..cd12d8049216350ebae814f55276cc01c590186e 100644 (file)
@@ -10,6 +10,8 @@
  *               Arnaldo Carvalho de Melo <acme@conectiva.com.br>, Mar 1999,
  *               Phillip Kesling <pkesling@sgi.com>, Mar 2003.
  */
+
+#include <libsmartcols.h>
 #include "c.h"
 #include "nls.h"
 #include "all-io.h"
@@ -1078,14 +1080,14 @@ static int sgi_toggle_partition_flag(struct fdisk_context *cxt, size_t i, unsign
 static const struct fdisk_column sgi_columns[] =
 {
        { FDISK_COL_DEVICE,     N_("Device"),    10,    0 },
-       { FDISK_COL_START,      N_("Start"),      5,    TT_FL_RIGHT },
-       { FDISK_COL_END,        N_("End"),        5,    TT_FL_RIGHT },
-       { FDISK_COL_SECTORS,    N_("Sectors"),    5,    TT_FL_RIGHT },
-       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    TT_FL_RIGHT },
-       { FDISK_COL_SIZE,       N_("Size"),       5,    TT_FL_RIGHT, FDISK_COLFL_EYECANDY },
-       { FDISK_COL_TYPEID,     N_("Id"),         2,    TT_FL_RIGHT },
-       { FDISK_COL_TYPE,       N_("Type"),     0.1,    TT_FL_TRUNC, FDISK_COLFL_EYECANDY },
-       { FDISK_COL_ATTR,       N_("Attrs"),      0,    TT_FL_RIGHT }
+       { FDISK_COL_START,      N_("Start"),      5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_END,        N_("End"),        5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_SECTORS,    N_("Sectors"),    5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_SIZE,       N_("Size"),       5,    SCOLS_FL_RIGHT, FDISK_COLFL_EYECANDY },
+       { FDISK_COL_TYPEID,     N_("Id"),         2,    SCOLS_FL_RIGHT },
+       { FDISK_COL_TYPE,       N_("Type"),     0.1,    SCOLS_FL_TRUNC, FDISK_COLFL_EYECANDY },
+       { FDISK_COL_ATTR,       N_("Attrs"),      0,    SCOLS_FL_RIGHT }
 };
 
 static const struct fdisk_label_operations sgi_operations =
index 0b79c2a28fb890abd86a19ae842f8674e00df6c1..6d68c7aa9980e867b72089f4f60eed1d125b6105 100644 (file)
@@ -12,6 +12,8 @@
 #include <unistd.h>            /* write */
 #include <sys/ioctl.h>         /* ioctl */
 
+#include <libsmartcols.h>
+
 #include "nls.h"
 #include "blkdev.h"
 #include "bitops.h"
@@ -987,14 +989,14 @@ static int sun_partition_is_used(
 static const struct fdisk_column sun_columns[] =
 {
        { FDISK_COL_DEVICE,     N_("Device"),    10,    0 },
-       { FDISK_COL_START,      N_("Start"),      5,    TT_FL_RIGHT },
-       { FDISK_COL_END,        N_("End"),        5,    TT_FL_RIGHT },
-       { FDISK_COL_SECTORS,    N_("Sectors"),    5,    TT_FL_RIGHT },
-       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    TT_FL_RIGHT },
-       { FDISK_COL_SIZE,       N_("Size"),       5,    TT_FL_RIGHT },
-       { FDISK_COL_TYPEID,     N_("Id"),         2,    TT_FL_RIGHT },
-       { FDISK_COL_TYPE,       N_("Type"),     0.1,    TT_FL_TRUNC },
-       { FDISK_COL_ATTR,       N_("Flags"),      0,    TT_FL_RIGHT }
+       { FDISK_COL_START,      N_("Start"),      5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_END,        N_("End"),        5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_SECTORS,    N_("Sectors"),    5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_CYLINDERS,  N_("Cylinders"),  5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_SIZE,       N_("Size"),       5,    SCOLS_FL_RIGHT },
+       { FDISK_COL_TYPEID,     N_("Id"),         2,    SCOLS_FL_RIGHT },
+       { FDISK_COL_TYPE,       N_("Type"),     0.1,    SCOLS_FL_TRUNC },
+       { FDISK_COL_ATTR,       N_("Flags"),      0,    SCOLS_FL_RIGHT }
 };
 
 const struct fdisk_label_operations sun_operations =
index 5365f2ccac571270068051b72bd8d3aea8e5f4d0..99dd67c79b18a286e0bae4e18e3aab68c06a67bd 100644 (file)
@@ -1,4 +1,5 @@
 
+#include <libsmartcols.h>
 #include "fdiskP.h"
 
 /**
@@ -539,7 +540,7 @@ int fdisk_table_to_string(struct fdisk_table *tb,
                          char **data)
 {
        int *org_cols = cols, rc = 0;
-       struct tt *tt = NULL;
+       struct libscols_table *table = NULL;
        const struct fdisk_column *col;
        struct fdisk_partition *pa = NULL;
        struct fdisk_iter itr;
@@ -560,8 +561,8 @@ int fdisk_table_to_string(struct fdisk_table *tb,
                        return rc;
        }
 
-       tt = tt_new_table(TT_FL_FREEDATA);
-       if (!tt) {
+       table = scols_new_table(NULL);
+       if (!table) {
                rc = -ENOMEM;
                goto done;
        }
@@ -570,14 +571,15 @@ int fdisk_table_to_string(struct fdisk_table *tb,
        for (j = 0; j < ncols; j++) {
                col = fdisk_label_get_column(cxt->label, cols[j]);
                if (col)
-                       tt_define_column(tt, col->name, col->width, col->tt_flags);
+                       if (!scols_table_new_column(table, col->name, col->width, col->scols_flags))
+                               goto done;
        }
 
        fdisk_reset_iter(&itr, FDISK_ITER_FORWARD);
 
-       /* convert partition to string and add to tt */
+       /* convert partition to string and add to table */
        while (fdisk_table_next_partition(tb, &itr, &pa) == 0) {
-               struct tt_line *ln = tt_add_line(tt, NULL);
+               struct libscols_line *ln = scols_table_new_line(table, NULL);
                if (!ln) {
                        rc = -ENOMEM;
                        goto done;
@@ -595,18 +597,18 @@ int fdisk_table_to_string(struct fdisk_table *tb,
                                continue;
                        if (fdisk_partition_to_string(pa, cxt, col->id, &cdata))
                                continue;
-                       tt_line_set_data(ln, j, cdata);
+                       scols_line_set_data(ln, j, cdata);
                }
        }
 
        rc = 0;
-       if (!tt_is_empty(tt))
-               rc = tt_print_table_to_string(tt, data);
+       if (!scols_table_is_empty(table))
+               rc = scols_print_table_to_string(table, data);
        else
-               DBG(TAB, ul_debugobj(tb, "tt empty"));
+               DBG(TAB, ul_debugobj(tb, "table empty"));
 done:
        if (org_cols != cols)
                free(cols);
-       tt_free_table(tt);
+       scols_unref_table(table);
        return rc;
 }