* [PATCH v2 1/2] column: Optionally keep empty lines in cols/rows mode
@ 2020-09-21 16:16 Lennard Hofmann
2020-09-21 16:26 ` [PATCH v2 2/2] column: Deprecate --table-empty-lines in favor of --keep-empty-lines Lennard Hofmann
2020-09-29 10:45 ` [PATCH v2 1/2] column: Optionally keep empty lines in cols/rows mode Karel Zak
0 siblings, 2 replies; 3+ messages in thread
From: Lennard Hofmann @ 2020-09-21 16:16 UTC (permalink / raw)
To: util-linux; +Cc: Lennard Hofmann
Signed-off-by: Lennard Hofmann <lennard.hofmann@web.de>
---
text-utils/column.c | 32 ++++++++++++++++++++++----------
1 file changed, 22 insertions(+), 10 deletions(-)
diff --git a/text-utils/column.c b/text-utils/column.c
index 238dbab41..f01499dca 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -487,8 +487,19 @@ static int add_emptyline_to_table(struct column_control *ctl)
return 0;
}
+static void add_entry(struct column_control *ctl, size_t *maxents, wchar_t *wcs)
+{
+ if (ctl->nents <= *maxents) {
+ *maxents += 1000;
+ ctl->ents = xrealloc(ctl->ents, *maxents * sizeof(wchar_t *));
+ }
+ ctl->ents[ctl->nents] = wcs;
+ ctl->nents++;
+}
+
static int read_input(struct column_control *ctl, FILE *fp)
{
+ wchar_t *empty = NULL;
char *buf = NULL;
size_t bufsz = 0;
size_t maxents = 0;
@@ -512,8 +523,15 @@ static int read_input(struct column_control *ctl, FILE *fp)
*p = '\0';
}
if (!str || !*str) {
- if (ctl->mode == COLUMN_MODE_TABLE && ctl->tab_empty_lines)
- add_emptyline_to_table(ctl);
+ if (ctl->tab_empty_lines) {
+ if (ctl->mode == COLUMN_MODE_TABLE) {
+ add_emptyline_to_table(ctl);
+ } else {
+ if (!empty)
+ empty = mbs_to_wcs("");
+ add_entry(ctl, &maxents, empty);
+ }
+ }
continue;
}
@@ -539,16 +557,10 @@ static int read_input(struct column_control *ctl, FILE *fp)
case COLUMN_MODE_FILLCOLS:
case COLUMN_MODE_FILLROWS:
- if (ctl->nents <= maxents) {
- maxents += 1000;
- ctl->ents = xrealloc(ctl->ents,
- maxents * sizeof(wchar_t *));
- }
- ctl->ents[ctl->nents] = wcs;
- len = width(ctl->ents[ctl->nents]);
+ add_entry(ctl, &maxents, wcs);
+ len = width(wcs);
if (ctl->maxlength < len)
ctl->maxlength = len;
- ctl->nents++;
break;
default:
free(wcs);
--
2.28.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] column: Deprecate --table-empty-lines in favor of --keep-empty-lines
2020-09-21 16:16 [PATCH v2 1/2] column: Optionally keep empty lines in cols/rows mode Lennard Hofmann
@ 2020-09-21 16:26 ` Lennard Hofmann
2020-09-29 10:45 ` [PATCH v2 1/2] column: Optionally keep empty lines in cols/rows mode Karel Zak
1 sibling, 0 replies; 3+ messages in thread
From: Lennard Hofmann @ 2020-09-21 16:26 UTC (permalink / raw)
To: util-linux; +Cc: Lennard Hofmann
`--table-empty-lines` gives the false impression that the option
only applies to table mode.
Signed-off-by: Lennard Hofmann <lennard.hofmann@web.de>
---
In comparison to the last patch, I also edited deprecated.txt and the
bash-completion. The PO files need to be updated, too, but I do not
know how.
Documentation/deprecated.txt | 7 +++++++
bash-completion/column | 2 +-
text-utils/column.1 | 8 +++++---
text-utils/column.c | 11 ++++++-----
4 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/Documentation/deprecated.txt b/Documentation/deprecated.txt
index 08ba8b974..4d4b309d6 100644
--- a/Documentation/deprecated.txt
+++ b/Documentation/deprecated.txt
@@ -2,6 +2,13 @@ The following is a list of commands or features that are deprecated. All
deprecated utils are in maintenance mode and we keep them in source tree for
backward compatibility only.
+
+what: column --table-empty-lines
+why: renamed to --keep-empty-lines
+since: v2.37
+
+--------------------------
+
what: hwclock --debug
why: renamed to --verbose, and may be repurposed later.
since: v2.32
diff --git a/bash-completion/column b/bash-completion/column
index 1f47aecc8..5ce56e76f 100644
--- a/bash-completion/column
+++ b/bash-completion/column
@@ -40,7 +40,7 @@ _column_module()
--table-right
--table-truncate
--table-wrap
- --table-empty-lines
+ --keep-empty-lines
--json
--tree
--tree-id
diff --git a/text-utils/column.1 b/text-utils/column.1
index 86886f3bf..d10fc7efb 100644
--- a/text-utils/column.1
+++ b/text-utils/column.1
@@ -110,9 +110,11 @@ hide all unnamed columns (see \-\-table-columns).
Specify columns order on output.
.IP "\fB\-n, \-\-table-name\fP \fIname\fP"
Specify the table name used for JSON output. The default is "table".
-.IP "\fB\-L, \-\-table\-empty\-lines\fP"
-Insert empty line to the table for each empty line on input. The default
-is ignore empty lines at all.
+.IP "\fB\-L, \-\-keep\-empty\-lines\fP"
+Preserve whitespace-only lines in the input. The default is ignore empty lines
+at all. This option’s original name was \-\-table-empty-lines but is now
+deprecated because it gives the false impression that the option only applies
+to table mode.
.IP "\fB\-r, \-\-tree\fP \fIcolumn\fP"
Specify column to use tree-like output. Note that the circular dependencies and
other anomalies in child and parent relation are silently ignored.
diff --git a/text-utils/column.c b/text-utils/column.c
index f01499dca..d251a710e 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -96,7 +96,7 @@ struct column_control {
unsigned int greedy :1,
json :1,
header_repeat :1,
- tab_empty_lines :1, /* --table-empty-lines */
+ keep_empty_lines :1, /* --keep-empty-lines */
tab_noheadings :1;
};
@@ -523,7 +523,7 @@ static int read_input(struct column_control *ctl, FILE *fp)
*p = '\0';
}
if (!str || !*str) {
- if (ctl->tab_empty_lines) {
+ if (ctl->keep_empty_lines) {
if (ctl->mode == COLUMN_MODE_TABLE) {
add_emptyline_to_table(ctl);
} else {
@@ -664,7 +664,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -R, --table-right <columns> right align text in these columns\n"), out);
fputs(_(" -T, --table-truncate <columns> truncate text in the columns when necessary\n"), out);
fputs(_(" -W, --table-wrap <columns> wrap text in the columns when necessary\n"), out);
- fputs(_(" -L, --table-empty-lines don't ignore empty lines\n"), out);
+ fputs(_(" -L, --keep-empty-lines don't ignore empty lines\n"), out);
fputs(_(" -J, --json use JSON output format for table\n"), out);
fputs(USAGE_SEPARATOR, out);
@@ -703,6 +703,7 @@ int main(int argc, char **argv)
{ "fillrows", no_argument, NULL, 'x' },
{ "help", no_argument, NULL, 'h' },
{ "json", no_argument, NULL, 'J' },
+ { "keep-empty-lines", no_argument, NULL, 'L' },
{ "output-separator", required_argument, NULL, 'o' },
{ "output-width", required_argument, NULL, 'c' },
{ "separator", required_argument, NULL, 's' },
@@ -717,7 +718,7 @@ int main(int argc, char **argv)
{ "table-right", required_argument, NULL, 'R' },
{ "table-truncate", required_argument, NULL, 'T' },
{ "table-wrap", required_argument, NULL, 'W' },
- { "table-empty-lines", no_argument, NULL, 'L' },
+ { "table-empty-lines", no_argument, NULL, 'L' }, /* deprecated */
{ "table-header-repeat", no_argument, NULL, 'e' },
{ "tree", required_argument, NULL, 'r' },
{ "tree-id", required_argument, NULL, 'i' },
@@ -768,7 +769,7 @@ int main(int argc, char **argv)
ctl.mode = COLUMN_MODE_TABLE;
break;
case 'L':
- ctl.tab_empty_lines = 1;
+ ctl.keep_empty_lines = 1;
break;
case 'l':
ctl.maxncols = strtou32_or_err(optarg, _("invalid columns limit argument"));
--
2.28.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/2] column: Optionally keep empty lines in cols/rows mode
2020-09-21 16:16 [PATCH v2 1/2] column: Optionally keep empty lines in cols/rows mode Lennard Hofmann
2020-09-21 16:26 ` [PATCH v2 2/2] column: Deprecate --table-empty-lines in favor of --keep-empty-lines Lennard Hofmann
@ 2020-09-29 10:45 ` Karel Zak
1 sibling, 0 replies; 3+ messages in thread
From: Karel Zak @ 2020-09-29 10:45 UTC (permalink / raw)
To: Lennard Hofmann; +Cc: util-linux
On Mon, Sep 21, 2020 at 06:16:20PM +0200, Lennard Hofmann wrote:
> text-utils/column.c | 32 ++++++++++++++++++++++----------
> 1 file changed, 22 insertions(+), 10 deletions(-)
Applied (both patches), thanks!
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-29 10:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-21 16:16 [PATCH v2 1/2] column: Optionally keep empty lines in cols/rows mode Lennard Hofmann
2020-09-21 16:26 ` [PATCH v2 2/2] column: Deprecate --table-empty-lines in favor of --keep-empty-lines Lennard Hofmann
2020-09-29 10:45 ` [PATCH v2 1/2] column: Optionally keep empty lines in cols/rows mode Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).