The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/1201

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Signed-off-by: Christian Brauner <christian.brau...@canonical.com>

Closes #1200.
From 27de259f33a4ef4ecb086d53341acaaac120ccdd Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brau...@canonical.com>
Date: Wed, 21 Sep 2016 09:15:14 +0200
Subject: [PATCH] tools: do not add trailing spaces on lxc-ls -1

Signed-off-by: Christian Brauner <christian.brau...@canonical.com>
---
 src/lxc/tools/lxc_ls.c | 24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)

diff --git a/src/lxc/tools/lxc_ls.c b/src/lxc/tools/lxc_ls.c
index e22c715..8e7cbef 100644
--- a/src/lxc/tools/lxc_ls.c
+++ b/src/lxc/tools/lxc_ls.c
@@ -144,7 +144,7 @@ static void ls_print_fancy_format(struct ls *l, struct 
lengths *lht,
  * Only print names of containers.
  */
 static void ls_print_names(struct ls *l, struct lengths *lht,
-               size_t ls_arr, size_t termwidth);
+               size_t ls_arr, size_t termwidth, bool list);
 
 /*
  * Print default fancy format.
@@ -264,7 +264,7 @@ int main(int argc, char *argv[])
                unsigned int cols = 0;
                if (!my_args.ls_line)
                        cols = ls_get_term_width();
-               ls_print_names(ls_arr, &max_len, ls_size, cols);
+               ls_print_names(ls_arr, &max_len, ls_size, cols, 
my_args.ls_line);
        }
 
        ret = EXIT_SUCCESS;
@@ -743,7 +743,7 @@ static struct ls *ls_new(struct ls **ls, size_t *size)
 }
 
 static void ls_print_names(struct ls *l, struct lengths *lht,
-               size_t size, size_t termwidth)
+               size_t size, size_t termwidth, bool list)
 {
        /* If list is empty do nothing. */
        if (size == 0)
@@ -752,14 +752,18 @@ static void ls_print_names(struct ls *l, struct lengths 
*lht,
        size_t i, len = 0;
        struct ls *m = NULL;
        for (i = 0, m = l; i < size; i++, m++) {
-               printf("%-*s", lht->name_length, m->name ? m->name : "-");
-               len += lht->name_length;
-               if ((len + lht->name_length) >= termwidth) {
-                       printf("\n");
-                       len = 0;
+               if (list) {
+                       printf("%s\n", m->name ? m->name : "-");
                } else {
-                       printf(" ");
-                       len++;
+                       printf("%-*s", lht->name_length, m->name ? m->name : 
"-");
+                       len += lht->name_length;
+                       if ((len + lht->name_length) >= termwidth) {
+                               printf("\n");
+                               len = 0;
+                       } else {
+                               printf(" ");
+                               len++;
+                       }
                }
        }
        if (len > 0)
_______________________________________________
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to