summaryrefslogtreecommitdiffstats
path: root/debian/patches/table-drop-trailing-white-spaces-of-the-last-cell-in-row.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/table-drop-trailing-white-spaces-of-the-last-cell-in-row.patch')
-rw-r--r--debian/patches/table-drop-trailing-white-spaces-of-the-last-cell-in-row.patch167
1 files changed, 167 insertions, 0 deletions
diff --git a/debian/patches/table-drop-trailing-white-spaces-of-the-last-cell-in-row.patch b/debian/patches/table-drop-trailing-white-spaces-of-the-last-cell-in-row.patch
new file mode 100644
index 0000000..fea1aec
--- /dev/null
+++ b/debian/patches/table-drop-trailing-white-spaces-of-the-last-cell-in-row.patch
@@ -0,0 +1,167 @@
+From: Yu Watanabe <watanabe.yu+github@gmail.com>
+Date: Tue, 2 Feb 2021 01:47:58 +0900
+Subject: table: drop trailing white spaces of the last cell in row
+
+Fixes #18415.
+
+(cherry picked from commit 71894e18313e41a72cecdc77fea5037f95d6903f)
+---
+ src/shared/format-table.c | 6 ++++++
+ src/test/test-format-table.c | 40 ++++++++++++++++++++--------------------
+ 2 files changed, 26 insertions(+), 20 deletions(-)
+
+diff --git a/src/shared/format-table.c b/src/shared/format-table.c
+index a13a198..2dc95e9 100644
+--- a/src/shared/format-table.c
++++ b/src/shared/format-table.c
+@@ -2155,6 +2155,12 @@ int table_print(Table *t, FILE *f) {
+ if (!aligned)
+ return -ENOMEM;
+
++ /* Drop trailing white spaces of last column when no cosmetics is set. */
++ if (j == display_columns - 1 &&
++ (!colors_enabled() || !table_data_color(d)) &&
++ (!urlify_enabled() || !d->url))
++ delete_trailing_chars(aligned, NULL);
++
+ free_and_replace(buffer, aligned);
+ field = buffer;
+ }
+diff --git a/src/test/test-format-table.c b/src/test/test-format-table.c
+index 24ee1df..b2943e6 100644
+--- a/src/test/test-format-table.c
++++ b/src/test/test-format-table.c
+@@ -29,7 +29,7 @@ static void test_issue_9549(void) {
+
+ printf("%s\n", formatted);
+ assert_se(streq(formatted,
+- "NAME TYPE RO USAGE CREATED MODIFIED \n"
++ "NAME TYPE RO USAGE CREATED MODIFIED\n"
+ "foooo raw no 673.6M Wed 2018-07-11 00:10:33 J… Wed 2018-07-11 00:16:00 JST\n"
+ ));
+ }
+@@ -72,7 +72,7 @@ static void test_multiline(void) {
+ "FOO BAR\n"
+ "three two\n"
+ "different lines\n"
+- "lines \n"));
++ "lines \n"));
+ formatted = mfree(formatted);
+
+ table_set_cell_height_max(table, (size_t) -1);
+@@ -82,7 +82,7 @@ static void test_multiline(void) {
+ "FOO BAR\n"
+ "three two\n"
+ "different lines\n"
+- "lines \n"));
++ "lines \n"));
+ formatted = mfree(formatted);
+
+ assert_se(table_add_many(table,
+@@ -123,7 +123,7 @@ static void test_multiline(void) {
+ "FOO BAR\n"
+ "three two\n"
+ "different lines\n"
+- "lines \n"
++ "lines \n"
+ "short a\n"
+ " pair\n"
+ "short2 a\n"
+@@ -138,7 +138,7 @@ static void test_multiline(void) {
+ "FOO BAR\n"
+ "three two\n"
+ "different lines\n"
+- "lines \n"
++ "lines \n"
+ "short a\n"
+ " pair\n"
+ "short2 a\n"
+@@ -186,7 +186,7 @@ static void test_strv(void) {
+ "FOO BAR\n"
+ "three two\n"
+ "different lines\n"
+- "lines \n"));
++ "lines \n"));
+ formatted = mfree(formatted);
+
+ table_set_cell_height_max(table, (size_t) -1);
+@@ -196,7 +196,7 @@ static void test_strv(void) {
+ "FOO BAR\n"
+ "three two\n"
+ "different lines\n"
+- "lines \n"));
++ "lines \n"));
+ formatted = mfree(formatted);
+
+ assert_se(table_add_many(table,
+@@ -237,7 +237,7 @@ static void test_strv(void) {
+ "FOO BAR\n"
+ "three two\n"
+ "different lines\n"
+- "lines \n"
++ "lines \n"
+ "short a\n"
+ " pair\n"
+ "short2 a\n"
+@@ -252,7 +252,7 @@ static void test_strv(void) {
+ "FOO BAR\n"
+ "three two\n"
+ "different lines\n"
+- "lines \n"
++ "lines \n"
+ "short a\n"
+ " pair\n"
+ "short2 a\n"
+@@ -333,7 +333,7 @@ static void test_strv_wrapped(void) {
+ assert_se(streq(formatted,
+ "FOO BAR\n"
+ "three different two lines\n"
+- "lines \n"
++ "lines \n"
+ "short a pair\n"
+ "short2 a eight line ćęłł\n"
+ " ___5___ ___6___…\n"));
+@@ -345,7 +345,7 @@ static void test_strv_wrapped(void) {
+ assert_se(streq(formatted,
+ "FOO BAR\n"
+ "three different two lines\n"
+- "lines \n"
++ "lines \n"
+ "short a pair\n"
+ "short2 a eight line ćęłł\n"
+ " ___5___ ___6___\n"
+@@ -358,7 +358,7 @@ static void test_strv_wrapped(void) {
+ assert_se(streq(formatted,
+ "FOO BAR\n"
+ "three different two lines\n"
+- "lines \n"
++ "lines \n"
+ "short a pair\n"
+ "short2 a eight line ćęłł\n"
+ " ___5___ ___6___\n"
+@@ -493,17 +493,17 @@ int main(int argc, char *argv[]) {
+ if (isatty(STDOUT_FILENO))
+ assert_se(streq(formatted,
+ " no a long f… no a long f… a long fi…\n"
+- " no fäää no fäää fäää \n"
+- " yes fäää yes fäää fäää \n"
+- " yes xxx yes xxx xxx \n"
+- "5min 5min \n"));
++ " no fäää no fäää fäää\n"
++ " yes fäää yes fäää fäää\n"
++ " yes xxx yes xxx xxx\n"
++ "5min 5min \n"));
+ else
+ assert_se(streq(formatted,
+ " no a long field no a long field a long field\n"
+- " no fäää no fäää fäää \n"
+- " yes fäää yes fäää fäää \n"
+- " yes xxx yes xxx xxx \n"
+- "5min 5min \n"));
++ " no fäää no fäää fäää\n"
++ " yes fäää yes fäää fäää\n"
++ " yes xxx yes xxx xxx\n"
++ "5min 5min \n"));
+
+ test_issue_9549();
+ test_multiline();