On Tue, May 20, 2014 at 01:31:07PM +0200, Pino Toscano wrote:
Print each line at once, making use of the padding features of
printf
instead of doing it manually.
---
fish/supported.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
diff --git a/fish/supported.c b/fish/supported.c
index 651e3aa..b49011a 100644
--- a/fish/supported.c
+++ b/fish/supported.c
@@ -49,20 +49,11 @@ run_supported (const char *cmd, size_t argc, char *argv[])
}
for (i = 0; groups[i] != NULL; ++i) {
- size_t l = strlen (groups[i]);
- size_t j;
- for (j = 0; j < len-l; ++j)
- putchar (' ');
- printf ("%s", groups[i]);
- putchar (' ');
-
char *gg[] = { groups[i], NULL };
int r = guestfs_available (g, gg);
- if (r == 0)
- printf ("%s", _("yes"));
- else
- printf ("%s", _("no"));
- putchar ('\n');
+ const char *str = r == 0 ? _("yes") : _("no");
+
+ printf ("%*s %s\n", (int) len, groups[i], str);
}
/* Restore error handler. */
--
1.9.0
ACK.
I have pushed this, thanks.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW