300 lines
9.9 KiB
Groff
300 lines
9.9 KiB
Groff
.CD "indent \(en reformat the layout of a program"
|
|
.SX "indent \fIin_file\fR [\fIout_file\fR] [\fIoptions\fR]
|
|
.FL "\fR(many)"
|
|
.EX "indent \(enbr \(enc25 prog.c " "Indent \fIprog.c\fR
|
|
.EX "indent \(ennpcs prog.c newprog.c" "Put output on \fInewprog.c"
|
|
.PP
|
|
\fIIndent\fR reads a C program in, rearranges the layout, and outputs a
|
|
new C program that will compile to the same executable binary as the original
|
|
one.
|
|
The difference between the input and output is that the output is in a standard
|
|
layout determined by a large number of options.
|
|
For most of the options there are two choices, one that enables it and one
|
|
that disables it.
|
|
.PP
|
|
If \fIindent\fR is called with no file files, it operates as a filter.
|
|
If called with one file name, that file is reformatted and the result
|
|
replaces the original file.
|
|
A backup is created, however, with the suffix \fI.BAK\fR.
|
|
If it is called with two file names, the first one is the input file and
|
|
the second one is the output file.
|
|
Only one file can be reformatted at a time (e.g., one cannot call \fIindent\fR
|
|
with *.c as argument; this is an error and will not work.).
|
|
.SS "Options"
|
|
.PP
|
|
Many options are available.
|
|
If you want to format a program to the \*(OQofficial\*(CQ MINIX format, use
|
|
\fIpretty\fR, which calls \fIindent\fR with the proper options and then
|
|
postprocesses the output.
|
|
The options listed below control the formatting style.
|
|
|
|
OPTION: \fB\(enbad\fR, \fB\(ennbad\fR
|
|
.PP
|
|
If \fB\(enbad\fR is specified, a blank line is forced
|
|
after every block of declarations. Default: \fB\(ennbad\fR.
|
|
|
|
OPTION: \fB\(enbap\fR, \fB\(ennbap\fR
|
|
.PP
|
|
If \fB\(enbap\fR is specified, a blank line is forced
|
|
after every procedure body. Default: \fB\(ennbap\fR.
|
|
|
|
OPTION: \fB\(enbbb\fR, \fB\(ennbbb\fR
|
|
.PP
|
|
If \fB\(enbbb\fR is specified, a blank line is forced
|
|
before every block comment. Default: \fB\(ennbbb\fR.
|
|
|
|
OPTION: \fB\(enbc\fR, \fB\(ennbc\fR
|
|
.PP
|
|
If \fB\(enbc\fR is specified, then a newline is forced
|
|
after each comma in a declaration. \fB\(ennbc\fR turns
|
|
off this option. The default is \fB\(ennbc\fR.
|
|
|
|
OPTION: \fB\(enbl\fR, \fB\(enbr\fR
|
|
.PP
|
|
Specifying \fB\(enbl\fR lines up compound statements
|
|
like this:
|
|
.HS
|
|
if (...)
|
|
{
|
|
code
|
|
}
|
|
.HS
|
|
Specifying \fB\(enbr\fR (the default) makes them look
|
|
like this:
|
|
.HS
|
|
if (...) {
|
|
code
|
|
}
|
|
.HS
|
|
|
|
OPTION: \fB\(enc\fIn\fR
|
|
.PP
|
|
The column in which comments on code start.
|
|
The default is 33.
|
|
|
|
OPTION: \fB\(encd\fIn\fR
|
|
.PP
|
|
The column in which comments on declarations
|
|
start. The default is for these comments to
|
|
start in the same column as those on code.
|
|
|
|
OPTION: \fB\(encdb\fR, \fB\(enncdb\fR
|
|
.PP
|
|
Enables (disables) the placement of comment
|
|
delimiters on blank lines. With this option
|
|
enabled, comments look like this:
|
|
.HS
|
|
/*
|
|
* this is a comment
|
|
*/
|
|
.HS
|
|
Rather than like this:
|
|
.HS
|
|
/* this is a comment */
|
|
.HS
|
|
This only affects block comments, not comments to the
|
|
right of code. The default is \fB\(encdb\fR.
|
|
|
|
OPTION: \fB\(ence\fR, \fB\(ennce\fR
|
|
.PP
|
|
Enables (disables) forcing \*(OQelse\*(CQs to cuddle
|
|
up to the immediately preceding \*(OQ}\*(CQ. The
|
|
default is \fB\(ence\fR.
|
|
|
|
OPTION: \fB\(enci\fIn\fR
|
|
.PP
|
|
Sets the continuation indent to be \fIn\fR. Continuation lines will be indented
|
|
that far from the beginning of the first line of the
|
|
statement. Parenthesized expressions have
|
|
extra indentation added to indicate the nesting, unless \fB\(enlp\fR
|
|
is in effect. \fB\(enci\fR defaults
|
|
to the same value as \fB\(eni\fR.
|
|
|
|
OPTION: \fB\(encli\fIn\fR
|
|
.PP
|
|
Causes case labels to be indented \fIn\fR tab stops
|
|
to the right of the containing switch statement. \fB\(encli\fR0.5 causes
|
|
case labels to be
|
|
indented half a tab stop. The default is \fB\(encli\fR0.
|
|
(This is the only option that takes a fractional argument.)
|
|
|
|
OPTION: \fB\(end\fI\s+2n\s0\fR
|
|
.PP
|
|
Controls the placement of comments which are
|
|
not to the right of code. Specifying \fB\(end\fR1
|
|
means that such comments are placed one
|
|
indentation level to the left of code. The
|
|
default \fB\(end\fR0 lines up these comments with the
|
|
code. See the section on comment indentation
|
|
below.
|
|
|
|
OPTION: \fB\(endi\fI\s+2n\s0\fR
|
|
.PP
|
|
Specifies the indentation, in character positions, from a declaration keyword
|
|
to the following identifier. The default is \fB\(endi\fR16.
|
|
|
|
OPTION: \fB\(endj\fR, \fB\(enndj\fR
|
|
.PP
|
|
\fB\(endj\fR left justifies declarations. \fB\(enndj\fR
|
|
indents declarations the same as code. The
|
|
default is \fB\(enndj\fR.
|
|
|
|
OPTION: \fB\(enei\fR, \fB\(ennei\fR
|
|
.PP
|
|
Enables (disables) special else\fB\(enif\fR processing.
|
|
If enabled, ifs following elses will
|
|
have the same indentation as the preceding if
|
|
statement. The default is \fB\(enei\fR.
|
|
|
|
OPTION: \fB\(enfc\fR1, \fB\(ennfc\fR1
|
|
.PP
|
|
Enables (disables) the formatting of comments
|
|
that start in column 1. Often, comments
|
|
whose leading \*(OQ/\*(CQ is in column 1 have been
|
|
carefully hand formatted by the programmer.
|
|
In such cases, \fB\(ennfc\fR1 should be used. The
|
|
default is \fB\(enfc\fR1.
|
|
|
|
OPTION: \fB\(eni\fI\s+1n\s0\fR
|
|
.PP
|
|
The number of spaces for one indentation
|
|
level. The default is 8.
|
|
|
|
OPTION: \fB\(enip\fR, \fB\(ennip\fR
|
|
.PP
|
|
Enables (disables) the indentation of parameter declarations from the
|
|
left margin. The default is \fB\(enip\fR.
|
|
|
|
OPTION: \fB\(enln\fR
|
|
.PP
|
|
Maximum length of an output line. The default is 78.
|
|
|
|
OPTION: \fB\(enlp\fR, \fB\(ennlp\fR
|
|
.PP
|
|
Lines up code surrounded by parenthesis in
|
|
continuation lines. If a line has a left
|
|
paren which is not closed on that line, then
|
|
continuation lines will be lined up to start
|
|
at the character position just after the left
|
|
paren.
|
|
|
|
OPTION: \fB\(ennpro\fR
|
|
.PP
|
|
Causes the profile files, \fI.indent.pro\fR in both the current directory
|
|
and the user's home directory to be ignored.
|
|
|
|
OPTION: \fB\(enpcs\fR, \fB\(ennpcs\fR
|
|
.PP
|
|
If true (\fB\(enpcs\fR) all procedure calls will have
|
|
a space inserted between the name and the \*(OQ(\*(CQ.
|
|
The default is \fB\(ennpcs\fR.
|
|
|
|
OPTION: \fB\(enps\fR, \fB\(ennps\fR
|
|
.PP
|
|
If true (\fB\(enps\fR) the pointer following operator \*(OQ\(en>\*(CQ will be surrounded by
|
|
spaces on either side. The default is \fB\(ennps\fR.
|
|
|
|
OPTION: \fB\(enpsl\fR, \fB\(ennpsl\fR
|
|
.PP
|
|
If true (\fB\(enpsl\fR) the names of procedures being
|
|
defined are placed in column 1 \(en their types,
|
|
if any, will be left on the previous lines.
|
|
The default is \fB\(enpsl\fR.
|
|
|
|
OPTION: \fB\(ensc\fR, \fB\(ennsc\fR
|
|
.PP
|
|
Enables (disables) the placement of asterisks
|
|
(*) at the left edge of all comments. The default is \fB\(ensc\fR.
|
|
|
|
OPTION: \fB\(ensob\fR, \fB\(ennsob\fR
|
|
.PP
|
|
If \fB\(ensob\fR is specified, \fIindent\fR will swallow
|
|
optional blank lines. You can use this to
|
|
get rid of blank lines after declarations. The default is \fB\(ennsob\fR.
|
|
|
|
OPTION: \fB\(enst\fR
|
|
.PP
|
|
Causes \fIindent\fR to take its input from \fIstdin\fR, and put its output
|
|
to \fIstdout\fR.
|
|
|
|
OPTION: \fB\(enT\fItypename\fR
|
|
.PP
|
|
Adds typename to the list of type keywords.
|
|
Names accumulate: \fB\(enT\fR can be specified more
|
|
than once. You need to specify all the
|
|
typenames that appear in your program that
|
|
are defined by #typedefs. Nothing will be
|
|
harmed if you miss a few, but the program
|
|
will not be formatted as nicely as it should.
|
|
This sounds like a painful thing to have to
|
|
do, but it is really a symptom of a problem in
|
|
C: typedef causes a syntactic change in the
|
|
language and \fIindent\fR cannot find all typedefs.
|
|
|
|
OPTION: \fB\(entroff\fR
|
|
.PP
|
|
Causes \fIindent\fR to format the program for processing by \fItroff\fR.
|
|
It will produce a fancy listing in much the same spirit as \fIvgrind\fR.
|
|
If the output file is not specified, the
|
|
default is standard output, rather than formatting in place.
|
|
|
|
OPTION: \fB\(env\fR, \fB\(ennv\fR
|
|
.PP
|
|
The \fB\(env\fR flag turns on verbose mode; \fB\(ennv\fR turns it off.
|
|
When in verbose mode, \fIindent\fR reports when it
|
|
splits one line of input into two or more
|
|
lines of output, and gives some size statistics at completion. The
|
|
default is \fB\(ennv\fR.
|
|
.SS "User Profiles"
|
|
.PP
|
|
You may set up your own profile of defaults to \fIindent\fR by
|
|
creating a file called \fI.indent.pro\fR in either your login
|
|
directory and/or the current directory and including whatever switches
|
|
you like. Switches in \fI.indent.pro\fR in the
|
|
current directory override those in your login directory
|
|
(with the exception of \fB\(enT\fR type definitions, which just accumulate).
|
|
If \fIindent\fR is run and a profile file exists, then
|
|
it is read to set up the program's defaults. The switches
|
|
should be separated by spaces, tabs or newlines. Switches
|
|
on the command line, however, override profile switches.
|
|
.SS "Comments"
|
|
.PP
|
|
\fIIndent\fR assumes that any comment with a dash
|
|
or star immediately after the start of comment (that is, \*(OQ/*\(en\*(CQ
|
|
or \*(OQ/**\*(CQ) is a
|
|
comment surrounded by a box of stars.
|
|
Each line of such a comment is left unchanged, except that
|
|
its indentation may be adjusted to account for the change in
|
|
indentation of the first line of the comment.
|
|
.PP
|
|
All other comments are treated as straight
|
|
text. Indent fits as many words (separated by blanks, tabs,
|
|
or newlines) on a line as possible. Blank lines break paragraphs.
|
|
.PP
|
|
If a comment is on a line with code it is started in the
|
|
comment column, which is set by the \fB\(encn\fR command line
|
|
parameter. Otherwise, the comment is started at \fIn\fR indentation levels
|
|
less than where code is currently being placed,
|
|
where n is specified by the \fB\(endn\fR command line parameter. If
|
|
the code on a line extends past the comment column, the comment starts
|
|
further to the right, and the right margin may
|
|
be automatically extended in extreme cases.
|
|
.SS "Preprocessor Lines"
|
|
.PP
|
|
In general, \fIindent\fR leaves preprocessor lines alone. The
|
|
only reformatting that it will do is to straighten up trailing comments.
|
|
It leaves embedded comments alone. Conditional compilation
|
|
(#ifdef...#endif) is recognized and
|
|
\fIindent\fR attempts to correctly compensate for the syntactic
|
|
peculiarities introduced.
|
|
.SS "C Syntax"
|
|
.PP
|
|
Indent understands a substantial amount about the syntax of
|
|
C, but it has a forgiving parser. It attempts to cope
|
|
with the usual sorts of incomplete and misformed syntax. In
|
|
particular, the use of macros like:
|
|
.HS
|
|
#define forever for(;;)
|
|
.HS
|
|
is handled properly.
|