INDENT(1,C) AIX Commands Reference INDENT(1,C)
-------------------------------------------------------------------------------
indent
PURPOSE
A C program formatter.
SYNTAX
+--------------------------------+ +--------------+
indent ---| +---------------+ |---| |---|
+- input-file -| |-+ +--- option ---+
+- output-file -+ ^ |
+----------+
DESCRIPTION
The indent command is a C program formatter. It reformats the C program in the
input-file according to the switches. The switches which can be specified are
described below. They may appear before or after the file names.
Note: If you only specify an input-file, the formatting is done "in-place."
That is, the formatted file is written back into input-file and a backup
copy of input-file is written in the current directory, with a file name
suffix of .BAK.
If output-file is specified, indent checks to make sure it is different from
input-file.
You may set up your own profile of defaults for the indent command by creating
a file called .indent.pro in your login directory or the current directory.
Include in it whatever switches you like. The switches should be separated by
spaces, tabs or newlines. Switches in .indent.pro in the current directory
override those in your login directory (with the exception of -T type
definitions, which just accumulate). If the indent command is run and a
profile file exists, then it is read to set up the program's defaults.
Switches on the command line, however, override profile switches.
Comments
"Box" comments. The indent command assumes that any comment with a dash or
star immediately after the start of comment (that is, '/*-' or '/**') 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.
Processed November 8, 1990 INDENT(1,C) 1
INDENT(1,C) AIX Commands Reference INDENT(1,C)
Straight text. All other comments are treated as straight text. The indent
command fits as many words (separated by blanks, tabs, or newlines) on a line
as possible. Blank lines break paragraphs.
Comment indentation.
If a comment is on a line with code it is started in the comment column set by
-cn. Otherwise, the comment is started at n indentation levels less than where
code is currently being placed, where n is specified by -dn. If the code on a
line extends past the comment column, the comment starts further to the right.
The right margin may be extended automatically in extreme cases.
Preprocessor lines.
In general, the indent command leaves preprocessor lines alone. The only
reformatting it does is to straighten up trailing comments. It leaves embedded
comments alone. Conditional compilation (#ifdef...#endif) is recognized and
indent attempts to compensate correctly for the syntactic peculiarities
introduced.
C syntax.
The indent command understands a substantial amount about C syntax, but has a
forgiving parser. It attempts to cope with the usual sorts of incomplete and
misformed syntax. In particular, the use of macros like:
#define forever for(;;)
is handled properly.
FLAGS
The options listed below control the formatting style imposed by the indent
command.
-bad, -nbad Forces or suppresses a blank line after every block of
declarations. Default: -nbad
-bap, -nbap Forces or suppresses a blank line after every procedure body.
Default: -nbap.
-bbb, -nbbb Forces or suppresses a blank line before every comment block.
Default: -nbbb
Note: The third character in a block comment must be a
blank. The third character in a box comment must be
either a dash (-) or an asterisk (*).
-bc, -nbc Forces or suppresses a newline after each comma in a
declaration. Default: -nbc
Processed November 8, 1990 INDENT(1,C) 2
INDENT(1,C) AIX Commands Reference INDENT(1,C)
-br, -bl -br formats compound statements thus:
if (...) {
code
}
-bl formats compound statements thus:
if (...)
{
code
}
Default: -br
-cn Sets the tab position where comments on code start. Default:
33
-cdn Sets tab position where comments on declarations start.
Default: Uses -c value
-cdb, -ncdb Enables or disables placing comment delimiters on blank
lines. With -cdb, comments look like this:
/*
* this is a comment
*/
With -ncdb, comments look like this:
/* this is a comment */
This only affects block comments, not comments to the right
of code. Default: -cdb
-ce, -nce Enables or disables forcing else's to follow the immediately
preceding '}.' Default: -ce
-cin Sets the continuation indent to n. Continuation lines will
be indented n positions from the beginning of the first line
of the statement. Expressions in parentheses have extra
indentation added to indicate the nesting, unless -lp is in
effect. Default: Uses -i value
-clin Causes case labels to be indented n positions to the right of
the containing switch statement. -cli0.5 causes case labels
to be indented half a tab stop. (This is the only option
that takes a fractional argument.) Default: -cli0
-dn Controls the placement of comments which are not to the right
of code. Specifying -d1 causes such comments to appear one
indentation level to the left of code. Default: -d0
Processed November 8, 1990 INDENT(1,C) 3
INDENT(1,C) AIX Commands Reference INDENT(1,C)
(comments are aligned with code) lines up these comments with
the code.
-din Specifies the number of positions to indent an identifier
from a preceding declaration keyword. Default: -di16
-dj, -ndj Left-justifies or indents declarations. Default: -ndj
-ei, -nei Enables or disables special else-if processing. -ei causes
ifs following elses to have the same indentation as the
preceding if statement. Default: -ei
-fc1, nfc1 Enables or disables formatting comments that start in column
1. Often, comments whose leading '/' is in column 1 have
been carefully hand-formatted by the programmer. In such
cases, use -nfc1. Default: -fc1
-in Sets the indentation level size. Default: 8 positions
-ip, -nip Enables or disables indenting parameter declarations.
Default: -ip
-1cn Sets the maximum length of the comment block to n. Default
value is specified by 1c flag or 78.
-ln Sets the maximum length of an output line to n. Default: 78
-lp, -nlp Aligns or leaves unaligned code surrounded by parentheses in
continuation lines. If a line has a left paren with no
matching right paren on that line, continuation lines will
start at the position following the left paren. With -nlp in
effect, such lines appear thus:
p1 = first_procedure(second_procedure(p2, p3),
third_procedure(p4, p5));
With -lp in effect, such lines appear thus:
p1 = first_procedure(second_procedure(p2, p3),
third_procedure(p4, p5));
Inserting two more newlines yields the following:
p1 = first_procedure(second_procedure(p2,
p3),
third_procedure(p4,
p5));
Default: -lp
Processed November 8, 1990 INDENT(1,C) 4
INDENT(1,C) AIX Commands Reference INDENT(1,C)
-npro Causes the profile files ./.indent.pro and ~/.indent.pro to
be ignored.
-pcs, -npcs Inserts or suppresses a space between each procedure call
name and the following '('. Default: -npcs
-ps, -nps Inserts or suppresses spaces on both sides of the pointer
following operator '->'. Default: -nps
-psl, -npsl -psl causes the names of procedures being defined to appear
left-justified. Their types, if any, remain on the previous
lines. Default: -psl
-sc, -nsc Enables or disables the placement of asterisks (*) to the
left of all comments. Default: -sc
-sob, -nsob Removes or retains optional blank lines. Use to remove blank
lines after declarations. Default: -nsob
-st Causes the indent command to take its input from stdin and
put its output to stdout.
-T typename Adds typename to the list of type keywords. Names
accumulate; -T can be specified more than once. Specify all
the typenames appearing in your program that are defined by
typedefs. No harm is done if you miss a few, but the program
won't be formatted as nicely. This may be a painful thing to
do, but it's a symptom of a problem in C. typedef causes a
syntactic change in the language and the indent command can't
find all typedefs.
-troff Causes the indent command to format the program for
processing by troff. It will produce a fancy listing in much
the same spirit as vgrind. If no output file is specified,
the default is standard output, rather than formatting in
place.
-v, -nv Turns on or off "verbose mode," which reports when indent
splits one line of input into two or more lines of output,
and gives some size statistics at completion. Default: -nv
FILES
./.indent.pro Profile file.
~/.indent.pro Profile file.
Processed November 8, 1990 INDENT(1,C) 5