mirror of
https://https.git.savannah.gnu.org/git/coreutils.git
synced 2026-01-27 01:44:21 +00:00
ptx: implement -t to change default width to 100
Align the -t implementation with the Heirloom project. * 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.
This commit is contained in:
parent
e1994cd9ac
commit
7531d3a205
2
NEWS
2
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.
|
||||
|
||||
@ -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 output 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
|
||||
|
||||
10
src/ptx.c
10
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. */
|
||||
|
||||
@ -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"}],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user