312 lines
12 KiB
HTML
312 lines
12 KiB
HTML
<HTML>
|
|
<HEAD>
|
|
<TITLE>indent(9)</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<H1>indent(9)</H1>
|
|
<HR>
|
|
<PRE>
|
|
<STRONG>Command:</STRONG> <STRONG>indent</STRONG> <STRONG>-</STRONG> <STRONG>reformat</STRONG> <STRONG>the</STRONG> <STRONG>layout</STRONG> <STRONG>of</STRONG> <STRONG>a</STRONG> <STRONG>program</STRONG>
|
|
<STRONG>Syntax:</STRONG> <STRONG>indent</STRONG> <EM>in</EM>_<EM>file</EM> [<EM>out</EM>_<EM>file</EM>] [<EM>options</EM>]
|
|
<STRONG>Flags:</STRONG> (many)
|
|
<STRONG>Examples:</STRONG> indent -br -c25 prog.c # Indent <EM>prog</EM>.<EM>c</EM>
|
|
indent -npcs prog.c newprog.c # Put output on <EM>newprog</EM>.<EM>c</EM>
|
|
|
|
<EM>Indent</EM> 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.
|
|
|
|
If <EM>indent</EM> 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 .<EM>BAK</EM>. 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 <EM>indent</EM> with *.c as
|
|
argument; this is an error and will not work.).
|
|
|
|
<STRONG>Options</STRONG>
|
|
|
|
Many options are available. If you want to format a program to the
|
|
'official' MINIX format, use <EM>pretty</EM>, which calls <EM>indent</EM> with the proper
|
|
options and then postprocesses the output. The options listed below
|
|
control the formatting style.
|
|
|
|
OPTION: <STRONG>-bad</STRONG>, <STRONG>-nbad</STRONG>
|
|
|
|
If <STRONG>-bad</STRONG> is specified, a blank line is forced after every block of
|
|
declarations. Default: <STRONG>-nbad</STRONG>.
|
|
|
|
OPTION: <STRONG>-bap</STRONG>, <STRONG>-nbap</STRONG>
|
|
|
|
If <STRONG>-bap</STRONG> is specified, a blank line is forced after every procedure
|
|
body. Default: <STRONG>-nbap</STRONG>.
|
|
|
|
OPTION: <STRONG>-bbb</STRONG>, <STRONG>-nbbb</STRONG>
|
|
|
|
If <STRONG>-bbb</STRONG> is specified, a blank line is forced before every block
|
|
comment. Default: <STRONG>-nbbb</STRONG>.
|
|
|
|
OPTION: <STRONG>-bc</STRONG>, <STRONG>-nbc</STRONG>
|
|
|
|
If <STRONG>-bc</STRONG> is specified, then a newline is forced after each comma in a
|
|
declaration. <STRONG>-nbc</STRONG> turns off this option. The default is <STRONG>-nbc</STRONG>.
|
|
|
|
OPTION: <STRONG>-bl</STRONG>, <STRONG>-br</STRONG>
|
|
|
|
Specifying <STRONG>-bl</STRONG> lines up compound statements like this:
|
|
|
|
if (...)
|
|
{
|
|
code
|
|
}
|
|
|
|
Specifying <STRONG>-br</STRONG> (the default) makes them look like this:
|
|
|
|
if (...) {
|
|
code
|
|
}
|
|
|
|
|
|
OPTION: <STRONG>-c</STRONG><EM>n</EM>
|
|
|
|
The column in which comments on code start. The default is 33.
|
|
|
|
OPTION: <STRONG>-cd</STRONG><EM>n</EM>
|
|
|
|
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: <STRONG>-cdb</STRONG>, <STRONG>-ncdb</STRONG>
|
|
|
|
Enables (disables) the placement of comment delimiters on blank
|
|
lines. With this option enabled, comments look like this:
|
|
|
|
/*
|
|
* this is a comment
|
|
*/
|
|
|
|
Rather than like this:
|
|
|
|
/* this is a comment */
|
|
|
|
This only affects block comments, not comments to the right of code. The
|
|
default is <STRONG>-cdb</STRONG>.
|
|
|
|
OPTION: <STRONG>-ce</STRONG>, <STRONG>-nce</STRONG>
|
|
|
|
Enables (disables) forcing 'else's to cuddle up to the immediately
|
|
preceding '}'. The default is <STRONG>-ce</STRONG>.
|
|
|
|
OPTION: <STRONG>-ci</STRONG><EM>n</EM>
|
|
|
|
Sets the continuation indent to be <EM>n</EM>. 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 <STRONG>-lp</STRONG> is in effect. <STRONG>-ci</STRONG> defaults to the same value as <STRONG>-i</STRONG>.
|
|
OPTION: <STRONG>-cli</STRONG><EM>n</EM>
|
|
|
|
Causes case labels to be indented <EM>n</EM> tab stops to the right of the
|
|
containing switch statement. <STRONG>-cli</STRONG>0.5 causes case labels to be indented
|
|
half a tab stop. The default is <STRONG>-cli</STRONG>0. (This is the only option that
|
|
takes a fractional argument.)
|
|
|
|
OPTION: <STRONG>-d</STRONG><EM>n</EM>
|
|
|
|
Controls the placement of comments which are not to the right of
|
|
code. Specifying <STRONG>-d</STRONG>1 means that such comments are placed one
|
|
indentation level to the left of code. The default <STRONG>-d</STRONG>0 lines up these
|
|
comments with the code. See the section on comment indentation below.
|
|
|
|
OPTION: <STRONG>-di</STRONG><EM>n</EM>
|
|
|
|
Specifies the indentation, in character positions, from a
|
|
declaration keyword to the following identifier. The default is <STRONG>-di</STRONG>16.
|
|
|
|
OPTION: <STRONG>-dj</STRONG>, <STRONG>-ndj</STRONG>
|
|
|
|
<STRONG>-dj</STRONG> left justifies declarations. <STRONG>-ndj</STRONG> indents declarations the
|
|
same as code. The default is <STRONG>-ndj</STRONG>.
|
|
|
|
OPTION: <STRONG>-ei</STRONG>, <STRONG>-nei</STRONG>
|
|
|
|
Enables (disables) special else<STRONG>-if</STRONG> processing. If enabled, ifs
|
|
following elses will have the same indentation as the preceding if
|
|
statement. The default is <STRONG>-ei</STRONG>.
|
|
|
|
OPTION: <STRONG>-fc</STRONG>1, <STRONG>-nfc</STRONG>1
|
|
|
|
Enables (disables) the formatting of 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, <STRONG>-nfc</STRONG>1 should be used.
|
|
The default is <STRONG>-fc</STRONG>1.
|
|
|
|
OPTION: <STRONG>-i</STRONG><EM>n</EM>
|
|
|
|
The number of spaces for one indentation level. The default is 8.
|
|
|
|
OPTION: <STRONG>-ip</STRONG>, <STRONG>-nip</STRONG>
|
|
|
|
Enables (disables) the indentation of parameter declarations from
|
|
the left margin. The default is <STRONG>-ip</STRONG>.
|
|
|
|
OPTION: <STRONG>-ln</STRONG>
|
|
|
|
|
|
|
|
Maximum length of an output line. The default is 78.
|
|
|
|
OPTION: <STRONG>-lp</STRONG>, <STRONG>-nlp</STRONG>
|
|
|
|
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: <STRONG>-npro</STRONG>
|
|
|
|
Causes the profile files, .<EM>indent</EM>.<EM>pro</EM> in both the current directory
|
|
and the user's home directory to be ignored.
|
|
|
|
OPTION: <STRONG>-pcs</STRONG>, <STRONG>-npcs</STRONG>
|
|
|
|
If true (<STRONG>-pcs</STRONG>) all procedure calls will have a space inserted
|
|
between the name and the '('. The default is <STRONG>-npcs</STRONG>.
|
|
|
|
OPTION: <STRONG>-ps</STRONG>, <STRONG>-nps</STRONG>
|
|
|
|
If true (<STRONG>-ps</STRONG>) the pointer following operator '->' will be
|
|
surrounded by spaces on either side. The default is <STRONG>-nps</STRONG>.
|
|
|
|
OPTION: <STRONG>-psl</STRONG>, <STRONG>-npsl</STRONG>
|
|
|
|
If true (<STRONG>-psl</STRONG>) the names of procedures being defined are placed in
|
|
column 1 - their types, if any, will be left on the previous lines. The
|
|
default is <STRONG>-psl</STRONG>.
|
|
|
|
OPTION: <STRONG>-sc</STRONG>, <STRONG>-nsc</STRONG>
|
|
|
|
Enables (disables) the placement of asterisks (*) at the left edge
|
|
of all comments. The default is <STRONG>-sc</STRONG>.
|
|
|
|
OPTION: <STRONG>-sob</STRONG>, <STRONG>-nsob</STRONG>
|
|
|
|
If <STRONG>-sob</STRONG> is specified, <EM>indent</EM> will swallow optional blank lines.
|
|
You can use this to get rid of blank lines after declarations. The
|
|
default is <STRONG>-nsob</STRONG>.
|
|
|
|
OPTION: <STRONG>-st</STRONG>
|
|
|
|
Causes <EM>indent</EM> to take its input from <EM>stdin</EM>, and put its output to
|
|
<EM>stdout</EM>.
|
|
|
|
OPTION: <STRONG>-T</STRONG><EM>typename</EM>
|
|
|
|
|
|
|
|
Adds typename to the list of type keywords. Names accumulate: <STRONG>-T</STRONG>
|
|
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 <EM>indent</EM> cannot find all typedefs.
|
|
|
|
OPTION: <STRONG>-troff</STRONG>
|
|
|
|
Causes <EM>indent</EM> to format the program for processing by <EM>troff</EM>. It
|
|
will produce a fancy listing in much the same spirit as <EM>vgrind</EM>. If the
|
|
output file is not specified, the default is standard output, rather
|
|
than formatting in place.
|
|
|
|
OPTION: <STRONG>-v</STRONG>, <STRONG>-nv</STRONG>
|
|
|
|
The <STRONG>-v</STRONG> flag turns on verbose mode; <STRONG>-nv</STRONG> turns it off. When in
|
|
verbose mode, <EM>indent</EM> 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 <STRONG>-nv</STRONG>.
|
|
|
|
<STRONG>User</STRONG> <STRONG>Profiles</STRONG>
|
|
|
|
You may set up your own profile of defaults to <EM>indent</EM> by creating a
|
|
file called .<EM>indent</EM>.<EM>pro</EM> in either your login directory and/or the
|
|
current directory and including whatever switches you like. Switches in
|
|
.<EM>indent</EM>.<EM>pro</EM> in the current directory override those in your login
|
|
directory (with the exception of <STRONG>-T</STRONG> type definitions, which just
|
|
accumulate). If <EM>indent</EM> 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.
|
|
|
|
<STRONG>Comments</STRONG>
|
|
|
|
<EM>Indent</EM> 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.
|
|
|
|
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.
|
|
|
|
If a comment is on a line with code it is started in the comment
|
|
column, which is set by the <STRONG>-cn</STRONG> command line parameter. Otherwise, the
|
|
comment is started at <EM>n</EM> indentation levels less than where code is
|
|
currently being placed, where n is specified by the <STRONG>-dn</STRONG> 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.
|
|
|
|
<STRONG>Preprocessor</STRONG> <STRONG>Lines</STRONG>
|
|
|
|
In general, <EM>indent</EM> 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 <EM>indent</EM> attempts to correctly
|
|
compensate for the syntactic peculiarities introduced.
|
|
|
|
<STRONG>C</STRONG> <STRONG>Syntax</STRONG>
|
|
|
|
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:
|
|
|
|
#define forever for(;;)
|
|
|
|
is handled properly.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</PRE>
|
|
</BODY>
|
|
</HTML>
|