Discussion:
[libvirt] [PATCH 1/2] vsh-table: Get rid of trailing spaces
Simon Kobyda
2018-11-27 09:07:32 UTC
Permalink
Get rid of trailing spaces which can be found after last column in tables.

Signed-off-by: Simon Kobyda <***@redhat.com>
---
tools/vsh-table.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/vsh-table.c b/tools/vsh-table.c
index 9b4a34c1e6..fb656ffeb0 100644
--- a/tools/vsh-table.c
+++ b/tools/vsh-table.c
@@ -348,8 +348,10 @@ vshTableRowPrint(vshTableRowPtr row,
for (i = 0; i < row->ncells; i++) {
virBufferAsprintf(buf, " %s", row->cells[i]);

- for (j = 0; j < maxwidths[i] - widths[i] + 2; j++)
- virBufferAddChar(buf, ' ');
+ if (i < (row->ncells - 1)) {
+ for (j = 0; j < maxwidths[i] - widths[i] + 2; j++)
+ virBufferAddChar(buf, ' ');
+ }
}
virBufferAddChar(buf, '\n');
}
--
2.17.1
Simon Kobyda
2018-11-27 09:07:33 UTC
Permalink
Signed-off-by: Simon Kobyda <***@redhat.com>
---
tests/virshtest.c | 10 ++++----
tests/vshtabletest.c | 58 ++++++++++++++++++++++----------------------
2 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/tests/virshtest.c b/tests/virshtest.c
index 250efb7734..7fb701d580 100644
--- a/tests/virshtest.c
+++ b/tests/virshtest.c
@@ -96,9 +96,9 @@ static int testCompareListDefault(const void *data ATTRIBUTE_UNUSED)
{
const char *const argv[] = { VIRSH_DEFAULT, "list", NULL };
const char *exp = "\
- Id Name State \n\
+ Id Name State\n\
----------------------\n\
- 1 test running \n\
+ 1 test running\n\
\n";
return testCompareOutputLit(exp, NULL, argv);
}
@@ -107,10 +107,10 @@ static int testCompareListCustom(const void *data ATTRIBUTE_UNUSED)
{
const char *const argv[] = { VIRSH_CUSTOM, "list", NULL };
const char *exp = "\
- Id Name State \n\
+ Id Name State\n\
----------------------\n\
- 1 fv0 running \n\
- 2 fc4 running \n\
+ 1 fv0 running\n\
+ 2 fc4 running\n\
\n";
return testCompareOutputLit(exp, NULL, argv);
}
diff --git a/tests/vshtabletest.c b/tests/vshtabletest.c
index ff394f65ca..e795c5afc0 100644
--- a/tests/vshtabletest.c
+++ b/tests/vshtabletest.c
@@ -43,13 +43,13 @@ testVshTableHeader(const void *opaque ATTRIBUTE_UNUSED)
int ret = 0;
char *act = NULL;
const char *exp =
-" 1 fedora28 running \n"
-" 2 rhel7.5 running \n";
+" 1 fedora28 running\n"
+" 2 rhel7.5 running\n";
const char *exp2 =
-" Id Name State \n"
+" Id Name State\n"
"--------------------------\n"
-" 1 fedora28 running \n"
-" 2 rhel7.5 running \n";
+" 1 fedora28 running\n"
+" 2 rhel7.5 running\n";

vshTablePtr table = vshTableNew("Id", "Name", "State",
NULL); //to ask about return
@@ -118,10 +118,10 @@ testUnicode(const void *opaque ATTRIBUTE_UNUSED)
char *act = NULL;

const char *exp =
-" Id 名稱 государство \n"
+" Id 名稱 государство\n"
"-----------------------------------------\n"
-" 1 fedora28 running \n"
-" 2 つへソrhel7.5つへソ running \n";
+" 1 fedora28 running\n"
+" 2 つへソrhel7.5つへソ running\n";
vshTablePtr table;

table = vshTableNew("Id", "名稱", "государство", NULL);
@@ -150,10 +150,10 @@ testUnicodeArabic(const void *opaque ATTRIBUTE_UNUSED)
char *act = NULL;

const char *exp =
-" ﻡﺍ ﻢﻣﺍ ﻕﺎﺌﻣﺓ ﺓ ﺎﻠﺼﻋ ﺍﻸﺜﻧﺎﻧ \n"
+" ﻡﺍ ﻢﻣﺍ ﻕﺎﺌﻣﺓ ﺓ ﺎﻠﺼﻋ ﺍﻸﺜﻧﺎﻧ\n"
"-------------------------------------------------------------------------------------------\n"
-" 1 ﻉﺪﻴﻟ ﺎﻠﺜﻘﻴﻟ ﻕﺎﻣ ﻊﻧ, ٣٠ ﻎﻴﻨﻳﺍ ﻮﺘﻧﺎﻤﺗ ﺎﻠﺛﺎﻠﺛ، ﺄﺳﺭ, ﺩﻮﻟ ﺩﻮﻟ. ﺄﻣﺎﻣ ﺍ ﺎﻧ ﻲﻜﻧ \n"
-" ﺺﻔﺣﺓ ﺖﻜﺘﻴﻛﺍً ﻊﻟ, ﺎﻠﺠﻧﻭﺩ ﻭﺎﻠﻌﺗﺍﺩ ﺵﺭ \n";
+" 1 ﻉﺪﻴﻟ ﺎﻠﺜﻘﻴﻟ ﻕﺎﻣ ﻊﻧ, ٣٠ ﻎﻴﻨﻳﺍ ﻮﺘﻧﺎﻤﺗ ﺎﻠﺛﺎﻠﺛ، ﺄﺳﺭ, ﺩﻮﻟ ﺩﻮﻟ. ﺄﻣﺎﻣ ﺍ ﺎﻧ ﻲﻜﻧ\n"
+" ﺺﻔﺣﺓ ﺖﻜﺘﻴﻛﺍً ﻊﻟ, ﺎﻠﺠﻧﻭﺩ ﻭﺎﻠﻌﺗﺍﺩ ﺵﺭ\n";
vshTablePtr table;
wchar_t wc;

@@ -192,10 +192,10 @@ testUnicodeZeroWidthChar(const void *opaque ATTRIBUTE_UNUSED)
int ret = 0;
vshTablePtr table = NULL;
const char *exp =
-" I\u200Bd Name \u200BStatus \n"
+" I\u200Bd Name \u200BStatus\n"
"--------------------------\n"
-" 1\u200B fedora28 run\u200Bning \n"
-" 2 rhel7.5 running \n";
+" 1\u200B fedora28 run\u200Bning\n"
+" 2 rhel7.5 running\n";
char *act = NULL;
wchar_t wc;

@@ -229,10 +229,10 @@ testUnicodeCombiningChar(const void *opaque ATTRIBUTE_UNUSED)
int ret = 0;
vshTablePtr table = NULL;
const char *exp =
-" Id Náme Ⓢtatus \n"
+" Id Náme Ⓢtatus\n"
"--------------------------\n"
-" 1 fědora28 running \n"
-" 2 rhel running \n";
+" 1 fědora28 running\n"
+" 2 rhel running\n";
char *act = NULL;

table = vshTableNew("Id", "Náme", "Ⓢtatus", NULL);
@@ -258,10 +258,10 @@ testUnicodeNonPrintableChar(const void *opaque ATTRIBUTE_UNUSED)
int ret = 0;
vshTablePtr table = NULL;
const char *exp =
-" I\\x09d Name Status \n"
+" I\\x09d Name Status\n"
"----------------------------------\n"
-" 1 f\\x07edora28 running \n"
-" 2 rhel7.5 running \n";
+" 1 f\\x07edora28 running\n"
+" 2 rhel7.5 running\n";
char *act = NULL;

table = vshTableNew("I\td", "Name", "Status", NULL);
@@ -288,20 +288,20 @@ testNTables(const void *opaque ATTRIBUTE_UNUSED)
vshTablePtr table2 = NULL;
vshTablePtr table3 = NULL;
const char *exp1 =
-" Id Name Status \n"
+" Id Name Status\n"
"--------------------------\n"
-" 1 fedora28 running \n"
-" 2 rhel7.5 running \n";
+" 1 fedora28 running\n"
+" 2 rhel7.5 running\n";
const char *exp2 =
-" Id Name Status \n"
+" Id Name Status\n"
"---------------------\n";
const char *exp3 =
-" Id \n"
+" Id\n"
"-----\n"
-" 1 \n"
-" 2 \n"
-" 3 \n"
-" 4 \n";
+" 1\n"
+" 2\n"
+" 3\n"
+" 4\n";
char *act1 = NULL;
char *act2 = NULL;
char *act3 = NULL;
--
2.17.1
Michal Privoznik
2018-11-28 12:25:31 UTC
Permalink
Right now, each line in last column of our table leaves trailing spaces.
Let's get rid of it.
vsh-table: Get rid of trailing spaces
tests: Remove trailing spaces in test cases
tests/virshtest.c | 10 ++++----
tests/vshtabletest.c | 58 ++++++++++++++++++++++----------------------
tools/vsh-table.c | 6 +++--
3 files changed, 38 insertions(+), 36 deletions(-)
The second patch should have been squashed into the first one. The
reason is that we require that after each commit 'make all syntax-check
check' passes.

Squashed them together, ACKed and pushed.

Michal

Loading...