PWB1/usr/man/man1/reform.1

Compare this file to the similar file:
Show the results in this format:

.if n .tr !|
.if n .ds v !
.th REFORM I 5/31/77
.sh NAME
reform \*- reformat text file
.sh SYNOPSIS
.bd reform
[\fItabspec1 \fP[\fItabspec2\fP]]
[\fB+b\fIn\fR]
[\fB+e\fR\fIn\fR]
[\fB+f\fR]
[\fB+i\fR\fIn\fR]
[\fB+m\fR\fIn\fR]
[\fB+p\fR\fIn\fR]
[\fB+s\fR]
[\fB+t\fIn\fR]
.sh DESCRIPTION
.it Reform
reads each line of the standard input file, reformats it, and
then writes it to the standard output.
Various combinations of reformatting operations can be selected, of
which the most common involve rearrangement of tab characters.
It is often used to trim trailing blanks,
truncate lines to a specified length,
or prepend blanks to lines.
.s3
.it Reform
first scans its arguments, which may be given in
any order.
It then processes its input file, performing the
following actions upon each line, in the order given:
.s3
.lp +3 2
\*-	A line is read from the standard input.
.s3
.lp +3 2
\*-	If
\fB+s\fR
is given, all characters up to the first tab are stripped off
and saved for later addition to the end of the line.
Presumably, these characters comprise an SCCS SID produced by
.it get\^\c
(I).
.s3
.lp +3 2
\*-	The line is expanded into a tabless form, by replacing tabs with
blanks according to the
.it input
tab specification \fItabspec1\fR.
.s3
.lp +3 2
\*-	If \fB+p\fIn\fR is given,
\fIn\fR blanks are prepended to the line.
.s3
.lp +3 2
\*-	If \fB+t\fIn\fR is given, the line is truncated
to a length of \fIn\fR characters.
.s3
.lp +3 2
\*-	All trailing blanks are now removed.
.s3
.lp +3 2
\*-	If \fB+e\fIn\fR is included, the line is extended out with blanks to
the length of \fIn\fR characters.
.s3
.lp +3 2
\*-	If
\fB+s\fR
is given, the previously-saved SCCS SID is added
to the end of the line.
.s3
.lp +3 2
\*-	If \fB+b\fIn\fR is given,
the \fIn\fR characters at the beginning of the line are
converted to blanks,
if and only if all of them are either digits or blanks.
.s3
.lp +3 2
\*-	If \fB+m\fIn\fR is included, the line is moved left, i.e.,
\fIn\fR characters are removed from the beginning of the line.
.s3
.lp +3 2
\*-	The line is now contracted by replacing some blanks with
tab characters according to the list of tabs indicated by the
.it output
tab
specification \fItabspec2\fR, and is written to the standard output file.
Option \fB+i\fR controls the method of contraction (see below).
.s2
.i0
The various arguments accepted by
.it reform
are as follows:
.s3
.lp +10 9
\fItabspec1\fR	describes the tab stops assumed for the input file.
This tab specification may take on any of the forms described in
.it tabs\^\c
(I).
In addition, the operand
``\fB\*-\*-\fP''
indicates that the tab specification is to
be found in the first line read from the standard input.
If no legal tab specification is found there, \fB\*-8\fR is assumed.
If
\fItabspec1\fR
is omitted entirely, ``\fB\*-\*-\fR'' is assumed.
.s3
.lp +10 9
\fItabspec2\fR	describes the tabs assumed for the output file.
It is interpreted in the same way as
\fItabspec1\fR,
except that omission of
\fItabspec2\fR
causes the value of
\fItabspec1\fR
to be used for
\fItabspec2\fR.
.s3
.i0
The remaining arguments are all optional and may be used in any combination,
although only a few combinations make much sense.
Specifying an argument causes an action to be performed, as
opposed to the usual default of not performing the action.
Some options include numeric values, which also have default values.
Option actions are applied to each line in the order described above.
Any line length mentioned applies to the length of a line just
before
the execution of the option described,
and the terminating newline is never counted in the line length.
.s3
.lp +10 9
\fB+b\fIn\fR	causes the first \fIn\fR characters of a line to be converted
to blanks, if and only if those characters include only blanks and digits.
If \fIn\fR is omitted, the default value is 6, which is useful in deleting
sequence numbers from COBOL programs.
.s3
.lp +10 9
\fB+e\fIn\fR	causes each line shorter than \fIn\fR characters to
be extended out with blanks to that length.
Omitting \fIn\fR implies a default value of 72.
This option is useful for those rare cases in which sequence
numbers need to be added to an existing unnumbered file.
The use of $ in editor regular expressions is more convenient if all lines
have equal length,
so that the user can issue editor commands such as:
.s3
s/$/00001000/
.s3
.lp +10 9
\fB+f\fR	causes a format line to be written to the standard output,
preceding any other lines written.
See
.it "fspec(V)"
for details regarding format specifications.
The format line is taken from \fItabspec2\fR, i.e., the line
normally appears as follows:
.s3
\fB<:t\*-\fItabspec2 \fBd:>\fR
.s3
If \fItabspec2\fR is of the form \fB\*-\*-\fIfilename\fR
(i.e., an indirect
reference to a tab specification in the first line of the named file),
then that tab specification
line is written to the standard output.
.s3
.lp +10 9
\fB+i\fIn\fR	controls the technique used to compress interior blanks into
tabs.
Unless this option is specified, any sequence of 1 or more blanks
may be converted to a single
tab character if that sequence occurs just before a tab stop.
This causes no problems for blanks that occur before the first
nonblank character in a line, and it is always possible to convert the
result back to an equivalent tabless form.
However, occasionally an interior blank (one occurring after the first
nonblank) is converted to a tab
when this is not intended.
For instance, this might occur in any program written in a language
utilizing blanks as delimiters.
Any single blank might be converted to a tab if it
occurred just before a tab stop.
Insertion or deletion of characters preceding such a tab may cause it to
be interpreted in an unexpected way at a later time.
If the \fB+i\fR option is used, no string of blanks may be converted to
a tab unless there are \fIn\fR or more contiguous blanks.
The default value is 2.
Note that leading blanks are always converted to tabs when possible.
.ft B
It is recommended that conversion of programs from non-PWB
to PWB systems use this option.
.ft R
.s3
.lp +10 9
\fB+m\fIn\fR	causes each line to be moved left \fIn\fR characters,
with a default value of 6.
This can be useful for crunching COBOL programs.
.s3
.lp +10 9
\fB+p\fIn\fR	causes \fIn\fR blanks to be prepended (default of 6 if
.it n
is
omitted).
This option is effectively the inverse of \fB+m\fIn\fR,
and is often useful for adjusting the position of
.it nroff(I)
output for terminals lacking both forms tractor positioning
and a settable left margin.
.s3
.lp +10 9
\fB+s\fR	is used with the
.bd \*-m
option of
.it get\^\c
(I).
The
.bd \*-m
option causes
.it get
to prepend to each generated line
the appropriate SCCS SID, followed by a tab.
The \fB+s\fR option causes
.it reform
to remove the SID from the front of the line,
save it, then add it later to the end of the line.
Because
.bd +e72
is implied by this option,
the effect is to produce 80-character card images with SCCS SID
in columns 73\*-80.
Up to 8 characters of the SID are shown;
if it is longer,
the eighth character is replaced by `*'
and any characters to the right of it are discarded.
.s3
.lp +10 9
\fB+t\fIn\fR	causes any line longer than \fIn\fR characters to be
truncated to that length.
If \fIn\fR is omitted, the length defaults to 72.
Sequence numbers can thus be removed
and any blanks immediately preceding them deleted.
.i0
.s2
The following illustrate typical uses of
.it reform.
The terms "PWB" and "OBJECT" below refer to UNIX and non\*-UNIX
computer systems, respectively.
Each arrow indicates the direction of conversion.
The character `?' indicates an arbitrary tab specification; see
.it "tabs(I)"
for descriptions of legal specifications.
.s1
.if t .ne1.5i
OBJECT \*-\*-\*-> PWB (i.e., manipulation of RJE output):
.s3
Note that files transferred by RJE from OBJECT to PWB
materialize with format \fB\*-8\fR.
.s3
reform \*-8 ? +t +f <oldfile >newfile   (into arbitrary format)
.br
reform \*-8 \*-c +t +b +i <oldfile >newfile (into COBOL)
.br
reform \*-8 \*-c3 +t +m +i <oldfile >newfile  (into COBOL, crunched)
.s3
NOTE: \*-c3 is the preferred format for COBOL;
it uses the least disk space of the COBOL formats.
.s0
.s1
PWB \*-\*-\*-> OBJECT (i.e., preparation of files for RJE submission):
.s3
reform ? \*-8 <oldfile >newfile  (from arbitrary format into \fB\*-8\fR)
.br
get \*-p \*-m sccsfile \*v reform +s \*v send ...
.s1
PWB ONLY (i.e., no involvement with other systems):
.s3
pr file \*v reform ? \*-0 <oldfile   (print on terminal without hardware tabs)
.br
reform ? \*-0 <oldfile >newfile  (convert file to tabless format)
.sh DIAGNOSTICS
All diagnostics are fatal, and the offending line is
displayed following the message.
.br
"line too long" a line exceeds 512 characters (in tabless form).
.br
"not SCCS \*-m" a line does not have at least one tab when
.bd +s
flag is used.
.br
Any of the diagnostics of
.it "tabs(I)"
can also appear.
.sh "EXIT CODES"
0 \*- normal
.br
1 \*- any error
.sh "SEE ALSO"
fspec(V), get(I), nroff(I), send(I), tabs(I)
.sh BUGS
.it Reform
is aware of the meanings of backspaces and escape sequences,
so that it can be
used as a postprocessor for
.it nroff.
However, be warned that the \fB+e, +m, +t\fR options only count characters,
not positions.
Anyone using these options on output containing backspaces or
halfline motions will probably obtain unexpected results.
.tr !!