perf: use format string of printf to align strings
PATCH 1/1 perf: use format string of printf to align strings
Instead of filling whitespaces to do alignment, use printf's format string.
Signed-off-by WANG Cong <[email protected]>
---
tools/perf/builtin-help.c +1 -2
@@ -286,8 +286,7 @@ void list_common_cmds_help(void)puts (" The most commonly used perf commands are:" );for (i =0 ; i <ARRAY_SIZE (common_cmds); i++) { -printf (" %s " , common_cmds[i].name); -mput_char (' ' , longest -strlen (common_cmds[i].name)); +printf (" %-*s " , longest, common_cmds[i].name);puts (common_cmds[i].help); } }
[tip:perf/core] perf: Use format string of printf to align strings
Commit-ID: 3912f2abc942a002ef611fc973add5e5eadb3432 Gitweb: http://git.kernel.org/tip/3912f2abc942a002ef611fc973add5e5eadb3432 Author: Amerigo Wang <[email protected]> AuthorDate: Mon, 14 Dec 2009 03:23:56 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 28 Dec 2009 09:03:16 +0100
perf: Use format string of printf to align strings
Instead of filling whitespaces to do alignment, use printf's format string.
This simplifies the code a bit.
Signed-off-by WANG Cong <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by Ingo Molnar <[email protected]>
--- tools/perf/builtin-help.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
tools/perf/builtin-help.c +1 -2
@@ -286,8 +286,7 @@ void list_common_cmds_help(void)puts (" The most commonly used perf commands are:" );for (i =0 ; i <ARRAY_SIZE (common_cmds); i++) { -printf (" %s " , common_cmds[i].name); -mput_char (' ' , longest -strlen (common_cmds[i].name)); +printf (" %-*s " , longest, common_cmds[i].name);puts (common_cmds[i].help); } }