This matches the FreeBSD documentation.
* src/ptx.c (usage): Describe -t, and also mention
the default width is 72 when not used.
* doc/coreutils.texi (ptx invocation): Likewise.
(main): Override the default width if -t is specified.
* tests/ptx/ptx.pl: Add test cases.
* NEWS: Mention the change in behavior.
---
NEWS | 2 ++
doc/coreutils.texi | 6 ++++++
src/ptx.c | 10 +++++++---
tests/ptx/ptx.pl | 7 +++++++
4 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/NEWS b/NEWS
index ca13267b3..eb9c5e2c4 100644
--- a/NEWS
+++ b/NEWS
@@ -53,6 +53,8 @@ GNU coreutils NEWS -*-
outline -*-
** Changes in behavior
+ 'ptx' -t is no longer a no-op, and now sets the default width to 100 columns.
+
'timeout' now honors ignored signals and will not propagate them. E.g.,
timeout(1) in a shell backgrounded job, will not terminate upon receiving
SIGINT or SIGQUIT, as these are ignored by default in shell background jobs.
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index 1b0c0db91..44e31acd2 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -5726,6 +5726,12 @@ Output format is further controlled by the following
options.
Select the size of the minimum white space gap between the fields on the
output line.
+@optItem{ptx,-t,}
+@optItemx{ptx,--typeset-mode,}
+Prepare the for a phototypesetter.
+I.e., change the default output width from 72 to 100 columns.
+This is equivalent to @option{--width=100}.
+
@optItem{ptx,-w,@w{ }@var{number}}
@optItemx{ptx,--width,=@var{number}}
Select the maximum output width of each final line. If references are
diff --git a/src/ptx.c b/src/ptx.c
index 92f948d0c..040c9e837 100644
--- a/src/ptx.c
+++ b/src/ptx.c
@@ -76,7 +76,7 @@ static bool gnu_extensions = true; /* trigger all GNU
extensions */
static bool auto_reference = false; /* refs are 'file_name:line_number:' */
static bool input_reference = false; /* refs at beginning of input lines */
static bool right_reference = false; /* output refs after right context */
-static idx_t line_width = 72; /* output line width in characters */
+static idx_t line_width = -1; /* output line width in characters */
static idx_t gap_size = 3; /* number of spaces between output fields */
static char const *truncation_string = "/";
/* string used to mark line truncations */
@@ -1710,7 +1710,7 @@ Output a permuted index, including context, of the words
in the input files.\n\
"), stdout);
fputs (_("\
-r, --references first field of each line is a reference\n\
- -t, --typeset-mode - not implemented -\n\
+ -t, --typeset-mode change the default width from 72 to 100\n\
-w, --width=NUMBER output width in columns, reference excluded\n\
"), stdout);
fputs (HELP_OPTION_DESCRIPTION, stdout);
@@ -1820,7 +1820,8 @@ main (int argc, char **argv)
break;
case 't':
- /* Yet to understand... */
+ if (line_width < 0)
+ line_width = 100;
break;
case 'w':
@@ -1882,6 +1883,9 @@ main (int argc, char **argv)
}
}
+ if (line_width < 0)
+ line_width = 72;
+
/* Process remaining arguments. If GNU extensions are enabled, process
all arguments as input parameters. If disabled, accept at most two
arguments, the second of which is an output parameter. */
diff --git a/tests/ptx/ptx.pl b/tests/ptx/ptx.pl
index 3ef86fe3d..1561996ca 100755
--- a/tests/ptx/ptx.pl
+++ b/tests/ptx/ptx.pl
@@ -27,6 +27,13 @@ my @Tests =
["1tok", '-w10', {IN=>"bar\n"}, {OUT=>" bar\n"}],
["2tok", '-w10', {IN=>"foo bar\n"}, {OUT=>" / bar\n foo/\n"}],
+# Ensure -w overrides -t
+["width-1", '-t -w10', {IN=>"bar\n"}, {OUT=>" " x 8 . "bar\n"}],
+# Ensure default width is 72
+["width-3", '', {IN=>"bar\n"}, {OUT=>" " x 39 . "bar\n"}],
+# Ensure default width is 100 with -t
+["width-2", '-t', {IN=>"bar\n"}, {OUT=>" " x 53 . "bar\n"}],
+
# with coreutils-6.12 and earlier, this would infloop with -wN, N < 10
["narrow", '-w2', {IN=>"qux\n"}, {OUT=>" qux\n"}],
["narrow-g", '-g1 -w2', {IN=>"ta\n"}, {OUT=>" ta\n"}],
--
2.52.0