1994-05-27 12:33:43 +00:00
|
|
|
.\" Copyright (c) 1980, 1990, 1993
|
|
|
|
.\" The Regents of the University of California. All rights reserved.
|
|
|
|
.\" Copyright (c) 1976 Board of Trustees of the University of Illinois.
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
|
|
.\" must display the following acknowledgement:
|
|
|
|
.\" This product includes software developed by the University of
|
|
|
|
.\" California, Berkeley and its contributors.
|
|
|
|
.\" 4. Neither the name of the University nor the names of its contributors
|
|
|
|
.\" may be used to endorse or promote products derived from this software
|
|
|
|
.\" without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" @(#)indent.1 8.1 (Berkeley) 7/1/93
|
1999-08-28 01:08:13 +00:00
|
|
|
.\" $FreeBSD$
|
1994-05-27 12:33:43 +00:00
|
|
|
.\"
|
2004-06-30 19:56:16 +00:00
|
|
|
.Dd June 29, 2004
|
1994-05-27 12:33:43 +00:00
|
|
|
.Dt INDENT 1
|
2001-07-10 14:16:33 +00:00
|
|
|
.Os
|
1994-05-27 12:33:43 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm indent
|
|
|
|
.Nd indent and format C program source
|
|
|
|
.Sh SYNOPSIS
|
1997-07-15 09:50:59 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
.Op Ar input-file Op Ar output-file
|
|
|
|
.Op Fl bad | Fl nbad
|
|
|
|
.Op Fl bap | Fl nbap
|
|
|
|
.Bk -words
|
|
|
|
.Op Fl bbb | Fl nbbb
|
|
|
|
.Ek
|
|
|
|
.Op Fl \&bc | Fl nbc
|
|
|
|
.Op Fl \&bl
|
|
|
|
.Op Fl \&br
|
|
|
|
.Op Fl c Ns Ar n
|
|
|
|
.Op Fl \&cd Ns Ar n
|
|
|
|
.Bk -words
|
|
|
|
.Op Fl cdb | Fl ncdb
|
|
|
|
.Ek
|
|
|
|
.Op Fl \&ce | Fl nce
|
|
|
|
.Op Fl \&ci Ns Ar n
|
|
|
|
.Op Fl cli Ns Ar n
|
|
|
|
.Op Fl d Ns Ar n
|
|
|
|
.Op Fl \&di Ns Ar n
|
|
|
|
.Bk -words
|
2004-06-29 18:57:13 +00:00
|
|
|
.Op Fl fbs | Fl nfbs
|
1994-05-27 12:33:43 +00:00
|
|
|
.Op Fl fc1 | Fl nfc1
|
2000-12-09 09:45:09 +00:00
|
|
|
.Op Fl fcb | Fl nfcb
|
1994-05-27 12:33:43 +00:00
|
|
|
.Ek
|
|
|
|
.Op Fl i Ns Ar n
|
|
|
|
.Op Fl \&ip | Fl nip
|
|
|
|
.Op Fl l Ns Ar n
|
|
|
|
.Op Fl \&lc Ns Ar n
|
2004-02-09 21:48:51 +00:00
|
|
|
.Op Fl \&ldi Ns Ar n
|
1994-05-27 12:33:43 +00:00
|
|
|
.Op Fl \&lp | Fl nlp
|
|
|
|
.Op Fl npro
|
|
|
|
.Op Fl pcs | Fl npcs
|
|
|
|
.Op Fl psl | Fl npsl
|
|
|
|
.Op Fl \&sc | Fl nsc
|
|
|
|
.Bk -words
|
|
|
|
.Op Fl sob | Fl nsob
|
|
|
|
.Ek
|
|
|
|
.Op Fl \&st
|
|
|
|
.Op Fl troff
|
2004-06-29 18:57:13 +00:00
|
|
|
.Op Fl ut | Fl nut
|
1994-05-27 12:33:43 +00:00
|
|
|
.Op Fl v | Fl \&nv
|
|
|
|
.Sh DESCRIPTION
|
2002-04-20 12:18:28 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility is a
|
|
|
|
.Em C
|
2004-07-02 22:22:35 +00:00
|
|
|
program formatter.
|
|
|
|
It reformats the
|
2002-04-20 12:18:28 +00:00
|
|
|
.Em C
|
1994-05-27 12:33:43 +00:00
|
|
|
program in the
|
|
|
|
.Ar input-file
|
2004-07-02 22:22:35 +00:00
|
|
|
according to the switches.
|
|
|
|
The switches which can be
|
|
|
|
specified are described below.
|
|
|
|
They may appear before or after the file
|
1994-05-27 12:33:43 +00:00
|
|
|
names.
|
|
|
|
.Pp
|
2004-07-03 00:24:45 +00:00
|
|
|
.Sy NOTE :
|
1994-05-27 12:33:43 +00:00
|
|
|
If you only specify an
|
2004-07-03 00:24:45 +00:00
|
|
|
.Ar input-file ,
|
1994-05-27 12:33:43 +00:00
|
|
|
the formatting is
|
|
|
|
done `in-place', that is, the formatted file is written back into
|
|
|
|
.Ar input-file
|
|
|
|
and a backup copy of
|
|
|
|
.Ar input-file
|
2004-07-02 22:22:35 +00:00
|
|
|
is written in the current directory.
|
|
|
|
If
|
1994-05-27 12:33:43 +00:00
|
|
|
.Ar input-file
|
|
|
|
is named
|
|
|
|
.Sq Pa /blah/blah/file ,
|
|
|
|
the backup file is named
|
|
|
|
.Pa file.BAK .
|
|
|
|
.Pp
|
|
|
|
If
|
|
|
|
.Ar output-file
|
|
|
|
is specified,
|
1997-07-15 09:50:59 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
checks to make sure it is different from
|
2004-07-03 00:24:45 +00:00
|
|
|
.Ar input-file .
|
1994-05-27 12:33:43 +00:00
|
|
|
.Pp
|
|
|
|
The options listed below control the formatting style imposed by
|
2000-11-20 19:21:22 +00:00
|
|
|
.Nm .
|
1994-05-27 12:33:43 +00:00
|
|
|
.Bl -tag -width Op
|
|
|
|
.It Fl bad , nbad
|
|
|
|
If
|
|
|
|
.Fl bad
|
|
|
|
is specified, a blank line is forced after every block of
|
2004-07-02 22:22:35 +00:00
|
|
|
declarations.
|
|
|
|
Default:
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl nbad .
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl bap , nbap
|
|
|
|
If
|
|
|
|
.Fl bap
|
2004-07-02 22:22:35 +00:00
|
|
|
is specified, a blank line is forced after every procedure body.
|
|
|
|
Default:
|
1994-05-27 12:33:43 +00:00
|
|
|
.Fl nbap .
|
|
|
|
.It Fl bbb , nbbb
|
|
|
|
If
|
|
|
|
.Fl bbb
|
2004-07-02 22:22:35 +00:00
|
|
|
is specified, a blank line is forced before every block comment.
|
|
|
|
Default:
|
1994-05-27 12:33:43 +00:00
|
|
|
.Fl nbbb .
|
|
|
|
.It Fl \&bc , nbc
|
|
|
|
If
|
|
|
|
.Fl \&bc
|
|
|
|
is specified, then a newline is forced after each comma in a declaration.
|
|
|
|
.Fl nbc
|
2004-07-02 22:22:35 +00:00
|
|
|
turns off this option.
|
|
|
|
Default:
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl \&nbc .
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl \&br , \&bl
|
|
|
|
Specifying
|
|
|
|
.Fl \&bl
|
1997-10-24 04:13:41 +00:00
|
|
|
lines-up compound statements like this:
|
1994-05-27 12:33:43 +00:00
|
|
|
.Bd -literal -offset indent
|
|
|
|
if (...)
|
|
|
|
{
|
|
|
|
code
|
|
|
|
}
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
Specifying
|
|
|
|
.Fl \&br
|
|
|
|
(the default) makes them look like this:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
if (...) {
|
|
|
|
code
|
|
|
|
}
|
|
|
|
.Ed
|
|
|
|
.Pp
|
1997-06-28 19:27:51 +00:00
|
|
|
.It Fl c Ns Ar n
|
2004-07-02 22:22:35 +00:00
|
|
|
The column in which comments on code start.
|
|
|
|
The default is 33.
|
1997-06-28 19:27:51 +00:00
|
|
|
.It Fl cd Ns Ar n
|
2004-07-02 22:22:35 +00:00
|
|
|
The column in which comments on declarations start.
|
|
|
|
The default
|
1994-05-27 12:33:43 +00:00
|
|
|
is for these comments to start in the same column as those on code.
|
|
|
|
.It Fl cdb , ncdb
|
2004-07-02 22:22:35 +00:00
|
|
|
Enables (disables) the placement of comment delimiters on blank lines.
|
|
|
|
With
|
1994-05-27 12:33:43 +00:00
|
|
|
this option enabled, comments look like this:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
/*
|
1996-01-20 07:29:11 +00:00
|
|
|
* this is a comment
|
|
|
|
*/
|
1994-05-27 12:33:43 +00:00
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
Rather than like this:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
/* this is a comment */
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
This only affects block comments, not comments to the right of
|
2004-07-02 22:22:35 +00:00
|
|
|
code.
|
|
|
|
The default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl cdb .
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl ce , nce
|
1997-10-24 04:13:41 +00:00
|
|
|
Enables (disables) forcing of `else's to cuddle up to the immediately preceding
|
2004-07-02 22:22:35 +00:00
|
|
|
`}'.
|
|
|
|
The default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl \&ce .
|
2001-07-15 08:06:20 +00:00
|
|
|
.It Fl \&ci Ns Ar n
|
1994-05-27 12:33:43 +00:00
|
|
|
Sets the continuation indent to be
|
2004-07-03 00:24:45 +00:00
|
|
|
.Ar n .
|
1994-05-27 12:33:43 +00:00
|
|
|
Continuation
|
|
|
|
lines will be indented that far from the beginning of the first line of the
|
2004-07-02 22:22:35 +00:00
|
|
|
statement.
|
|
|
|
Parenthesized expressions have extra indentation added to
|
1994-05-27 12:33:43 +00:00
|
|
|
indicate the nesting, unless
|
|
|
|
.Fl \&lp
|
2004-02-12 16:25:12 +00:00
|
|
|
is in effect
|
|
|
|
or the contination indent is exactly half of the main indent.
|
1994-05-27 12:33:43 +00:00
|
|
|
.Fl \&ci
|
|
|
|
defaults to the same value as
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl i .
|
2001-07-15 08:06:20 +00:00
|
|
|
.It Fl cli Ns Ar n
|
1994-05-27 12:33:43 +00:00
|
|
|
Causes case labels to be indented
|
|
|
|
.Ar n
|
|
|
|
tab stops to the right of the containing
|
|
|
|
.Ic switch
|
|
|
|
statement.
|
1996-10-23 07:02:48 +00:00
|
|
|
.Fl cli0.5
|
2004-07-02 22:22:35 +00:00
|
|
|
causes case labels to be indented half a tab stop.
|
|
|
|
The
|
1994-05-27 12:33:43 +00:00
|
|
|
default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl cli0 .
|
2001-07-15 08:06:20 +00:00
|
|
|
.It Fl d Ns Ar n
|
1994-05-27 12:33:43 +00:00
|
|
|
Controls the placement of comments which are not to the
|
2004-07-02 22:22:35 +00:00
|
|
|
right of code.
|
|
|
|
For example,
|
1994-05-27 12:33:43 +00:00
|
|
|
.Fl \&d\&1
|
|
|
|
means that such comments are placed one indentation level to the
|
2004-07-02 22:22:35 +00:00
|
|
|
left of code.
|
|
|
|
Specifying the default
|
1994-05-27 12:33:43 +00:00
|
|
|
.Fl \&d\&0
|
2004-07-02 22:22:35 +00:00
|
|
|
lines-up these comments with the code.
|
|
|
|
See the section on comment
|
1994-05-27 12:33:43 +00:00
|
|
|
indentation below.
|
2001-07-15 08:06:20 +00:00
|
|
|
.It Fl \&di Ns Ar n
|
2004-02-09 21:48:51 +00:00
|
|
|
Specifies the indentation, in character positions,
|
|
|
|
of global variable names and all struct/union member names
|
|
|
|
relative to the beginning of their type declaration.
|
|
|
|
The default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl di16 .
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl dj , ndj
|
|
|
|
.Fl \&dj
|
|
|
|
left justifies declarations.
|
|
|
|
.Fl ndj
|
2004-07-02 22:22:35 +00:00
|
|
|
indents declarations the same as code.
|
|
|
|
The default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl ndj .
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl \&ei , nei
|
|
|
|
Enables (disables) special
|
|
|
|
.Ic else-if
|
2004-07-02 22:22:35 +00:00
|
|
|
processing.
|
|
|
|
If it's enabled, an
|
1994-05-27 12:33:43 +00:00
|
|
|
.Ic if
|
|
|
|
following an
|
|
|
|
.Ic else
|
|
|
|
will have the same indentation as the preceding
|
|
|
|
.Ic \&if
|
2004-07-02 22:22:35 +00:00
|
|
|
statement.
|
|
|
|
The default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl ei .
|
2004-06-29 18:57:13 +00:00
|
|
|
.It Fl fbs , nfbs
|
|
|
|
Enables (disables) splitting the function declaration and opening brace
|
|
|
|
across two lines.
|
|
|
|
The default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl fbs .
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl fc1 , nfc1
|
|
|
|
Enables (disables) the formatting of comments that start in column 1.
|
|
|
|
Often, comments whose leading `/' is in column 1 have been carefully
|
2004-07-02 22:22:35 +00:00
|
|
|
hand formatted by the programmer.
|
|
|
|
In such cases,
|
1994-05-27 12:33:43 +00:00
|
|
|
.Fl nfc1
|
|
|
|
should be
|
2004-07-02 22:22:35 +00:00
|
|
|
used.
|
|
|
|
The default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl fc1 .
|
2000-12-09 09:45:09 +00:00
|
|
|
.It Fl fcb , nfcb
|
|
|
|
Enables (disables) the formatting of block comments (ones that begin
|
2000-12-09 19:03:21 +00:00
|
|
|
with `/*\\n').
|
|
|
|
Often, block comments have been not so carefully hand formatted by the
|
|
|
|
programmer, but reformatting that would just change the line breaks is not
|
|
|
|
wanted.
|
|
|
|
In such cases,
|
2000-12-09 09:45:09 +00:00
|
|
|
.Fl nfcb
|
2000-12-09 19:03:21 +00:00
|
|
|
should be used.
|
|
|
|
Block comments are then handled like box comments.
|
2000-12-09 09:45:09 +00:00
|
|
|
The default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl fcb .
|
2001-07-15 08:06:20 +00:00
|
|
|
.It Fl i Ns Ar n
|
2004-07-02 22:22:35 +00:00
|
|
|
The number of spaces for one indentation level.
|
|
|
|
The default is 8.
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl \&ip , nip
|
|
|
|
Enables (disables) the indentation of parameter declarations from the left
|
2004-07-02 22:22:35 +00:00
|
|
|
margin.
|
|
|
|
The default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl \&ip .
|
2001-07-15 08:06:20 +00:00
|
|
|
.It Fl l Ns Ar n
|
2004-07-02 22:22:35 +00:00
|
|
|
Maximum length of an output line.
|
|
|
|
The default is 78.
|
2004-02-09 21:48:51 +00:00
|
|
|
.It Fl \&ldi Ns Ar n
|
|
|
|
Specifies the indentation, in character positions,
|
|
|
|
of local variable names
|
|
|
|
relative to the beginning of their type declaration.
|
|
|
|
The default is for local variable names to be indented
|
|
|
|
by the same amount as global ones.
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl \&lp , nlp
|
2004-07-02 22:22:35 +00:00
|
|
|
Lines-up code surrounded by parenthesis in continuation lines.
|
|
|
|
If a line
|
1994-05-27 12:33:43 +00:00
|
|
|
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
|
2004-07-02 22:22:35 +00:00
|
|
|
paren.
|
|
|
|
For example, here is how a piece of continued code looks with
|
1994-05-27 12:33:43 +00:00
|
|
|
.Fl nlp
|
|
|
|
in effect:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
p1 = first_procedure(second_procedure(p2, p3),
|
1997-06-28 19:27:51 +00:00
|
|
|
\ \ third_procedure(p4, p5));
|
1994-05-27 12:33:43 +00:00
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
With
|
|
|
|
.Fl lp
|
|
|
|
in effect (the default) the code looks somewhat clearer:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
p1\ =\ first_procedure(second_procedure(p2,\ p3),
|
1997-06-28 19:27:51 +00:00
|
|
|
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ third_procedure(p4,\ p5));
|
1994-05-27 12:33:43 +00:00
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
Inserting two more newlines we get:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
p1\ =\ first_procedure(second_procedure(p2,
|
|
|
|
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ p3),
|
1997-06-28 19:27:51 +00:00
|
|
|
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ third_procedure(p4,
|
1994-05-27 12:33:43 +00:00
|
|
|
\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ p5));
|
|
|
|
.Ed
|
|
|
|
.It Fl npro
|
|
|
|
Causes the profile files,
|
|
|
|
.Sq Pa ./.indent.pro
|
|
|
|
and
|
|
|
|
.Sq Pa ~/.indent.pro ,
|
|
|
|
to be ignored.
|
|
|
|
.It Fl pcs , npcs
|
|
|
|
If true
|
|
|
|
.Pq Fl pcs
|
|
|
|
all procedure calls will have a space inserted between
|
2004-07-02 22:22:35 +00:00
|
|
|
the name and the `('.
|
|
|
|
The default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl npcs .
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl psl , npsl
|
|
|
|
If true
|
|
|
|
.Pq Fl psl
|
|
|
|
the names of procedures being defined are placed in
|
2004-07-02 22:22:35 +00:00
|
|
|
column 1 \- their types, if any, will be left on the previous lines.
|
|
|
|
The
|
1994-05-27 12:33:43 +00:00
|
|
|
default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl psl .
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl \&sc , nsc
|
|
|
|
Enables (disables) the placement of asterisks (`*'s) at the left edge of all
|
2004-07-02 22:22:35 +00:00
|
|
|
comments.
|
|
|
|
The default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl sc .
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl sob , nsob
|
|
|
|
If
|
|
|
|
.Fl sob
|
2004-07-02 22:22:35 +00:00
|
|
|
is specified, indent will swallow optional blank lines.
|
|
|
|
You can use this to
|
|
|
|
get rid of blank lines after declarations.
|
|
|
|
Default:
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl nsob .
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl \&st
|
|
|
|
Causes
|
1997-07-15 09:50:59 +00:00
|
|
|
.Nm
|
1997-10-24 04:13:41 +00:00
|
|
|
to take its input from stdin and put its output to stdout.
|
2001-07-15 08:06:20 +00:00
|
|
|
.It Fl T Ns Ar typename
|
1994-05-27 12:33:43 +00:00
|
|
|
Adds
|
|
|
|
.Ar typename
|
2004-07-02 22:22:35 +00:00
|
|
|
to the list of type keywords.
|
|
|
|
Names accumulate:
|
1994-05-27 12:33:43 +00:00
|
|
|
.Fl T
|
2004-07-02 22:22:35 +00:00
|
|
|
can be specified more than once.
|
|
|
|
You need to specify all the typenames that
|
1994-05-27 12:33:43 +00:00
|
|
|
appear in your program that are defined by
|
|
|
|
.Ic typedef
|
|
|
|
\- nothing will be
|
|
|
|
harmed if you miss a few, but the program won't be formatted as nicely as
|
2004-07-02 22:22:35 +00:00
|
|
|
it should.
|
|
|
|
This sounds like a painful thing to have to do, but it's really
|
1994-05-27 12:33:43 +00:00
|
|
|
a symptom of a problem in C:
|
|
|
|
.Ic typedef
|
|
|
|
causes a syntactic change in the
|
|
|
|
language and
|
1997-07-15 09:50:59 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
can't find all
|
|
|
|
instances of
|
|
|
|
.Ic typedef .
|
|
|
|
.It Fl troff
|
|
|
|
Causes
|
1997-07-15 09:50:59 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
to format the program for processing by
|
|
|
|
.Xr troff 1 .
|
|
|
|
It will produce a fancy
|
|
|
|
listing in much the same spirit as
|
|
|
|
.Xr vgrind 1 .
|
|
|
|
If the output file is not specified, the default is standard output,
|
|
|
|
rather than formatting in place.
|
2004-06-29 18:57:13 +00:00
|
|
|
.It Fl ut , nut
|
|
|
|
Enables (disables) the use of tab characters in the output.
|
|
|
|
Tabs are assumed to be aligned on columns divisble by 8.
|
|
|
|
The default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl ut .
|
1994-05-27 12:33:43 +00:00
|
|
|
.It Fl v , \&nv
|
|
|
|
.Fl v
|
|
|
|
turns on `verbose' mode;
|
|
|
|
.Fl \&nv
|
2004-07-02 22:22:35 +00:00
|
|
|
turns it off.
|
|
|
|
When in verbose mode,
|
1997-07-15 09:50:59 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
reports when it splits one line of input into two or more lines of output,
|
2004-07-02 22:22:35 +00:00
|
|
|
and gives some size statistics at completion.
|
|
|
|
The default is
|
2004-07-03 00:24:45 +00:00
|
|
|
.Fl \&nv .
|
1994-05-27 12:33:43 +00:00
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
You may set up your own `profile' of defaults to
|
1997-07-15 09:50:59 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
by creating a file called
|
|
|
|
.Pa .indent.pro
|
|
|
|
in your login directory and/or the current directory and including
|
2004-07-02 22:22:35 +00:00
|
|
|
whatever switches you like.
|
|
|
|
A `.indent.pro' in the current directory takes
|
|
|
|
precedence over the one in your login directory.
|
|
|
|
If
|
1997-07-15 09:50:59 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
is run and a profile file exists, then it is read to set up the program's
|
2004-07-02 22:22:35 +00:00
|
|
|
defaults.
|
|
|
|
Switches on the command line, though, always override profile
|
|
|
|
switches.
|
|
|
|
The switches should be separated by spaces, tabs or newlines.
|
1994-05-27 12:33:43 +00:00
|
|
|
.Pp
|
|
|
|
.Ss Comments
|
|
|
|
.Sq Em Box
|
|
|
|
.Em comments .
|
2002-04-20 12:18:28 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility
|
1994-05-27 12:33:43 +00:00
|
|
|
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.
|
|
|
|
.Pp
|
|
|
|
.Em Straight text .
|
|
|
|
All other comments are treated as straight text.
|
2002-04-20 12:18:28 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility fits as many words (separated by blanks, tabs, or newlines) on a
|
2004-07-02 22:22:35 +00:00
|
|
|
line as possible.
|
|
|
|
Blank lines break paragraphs.
|
1994-05-27 12:33:43 +00:00
|
|
|
.Pp
|
|
|
|
.Ss Comment indentation
|
|
|
|
If a comment is on a line with code it is started in the `comment column',
|
|
|
|
which is set by the
|
2001-07-15 08:06:20 +00:00
|
|
|
.Fl c Ns Ns Ar n
|
2004-07-02 22:22:35 +00:00
|
|
|
command line parameter.
|
|
|
|
Otherwise, the comment is started at
|
1994-05-27 12:33:43 +00:00
|
|
|
.Ar n
|
|
|
|
indentation levels less than where code is currently being placed, where
|
|
|
|
.Ar n
|
|
|
|
is specified by the
|
2001-07-15 08:06:20 +00:00
|
|
|
.Fl d Ns Ns Ar n
|
2004-07-02 22:22:35 +00:00
|
|
|
command line parameter.
|
|
|
|
If the code on a line extends past the comment
|
1994-05-27 12:33:43 +00:00
|
|
|
column, the comment starts further to the right, and the right margin may be
|
|
|
|
automatically extended in extreme cases.
|
|
|
|
.Pp
|
|
|
|
.Ss Preprocessor lines
|
|
|
|
In general,
|
1997-07-15 09:50:59 +00:00
|
|
|
.Nm
|
2004-07-02 22:22:35 +00:00
|
|
|
leaves preprocessor lines alone.
|
|
|
|
The only
|
|
|
|
reformatting that it will do is to straighten up trailing comments.
|
|
|
|
It
|
|
|
|
leaves embedded comments alone.
|
|
|
|
Conditional compilation
|
1994-05-27 12:33:43 +00:00
|
|
|
.Pq Ic #ifdef...#endif
|
|
|
|
is recognized and
|
1997-07-15 09:50:59 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
attempts to correctly
|
|
|
|
compensate for the syntactic peculiarities introduced.
|
|
|
|
.Pp
|
|
|
|
.Ss C syntax
|
2002-04-20 12:18:28 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility understands a substantial amount about the syntax of C, but it
|
2004-07-02 22:22:35 +00:00
|
|
|
has a `forgiving' parser.
|
|
|
|
It attempts to cope with the usual sorts of
|
|
|
|
incomplete and misformed syntax.
|
|
|
|
In particular, the use of macros like:
|
1994-05-27 12:33:43 +00:00
|
|
|
.Pp
|
|
|
|
.Dl #define forever for(;;)
|
|
|
|
.Pp
|
|
|
|
is handled properly.
|
|
|
|
.Sh ENVIRONMENT
|
2002-04-20 12:18:28 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility uses the
|
1994-05-27 12:33:43 +00:00
|
|
|
.Ev HOME
|
|
|
|
environment variable.
|
|
|
|
.Sh FILES
|
|
|
|
.Bl -tag -width "./.indent.pro" -compact
|
|
|
|
.It Pa ./.indent.pro
|
|
|
|
profile file
|
|
|
|
.It Pa ~/.indent.pro
|
|
|
|
profile file
|
|
|
|
.El
|
|
|
|
.Sh HISTORY
|
|
|
|
The
|
1997-07-15 09:50:59 +00:00
|
|
|
.Nm
|
1994-05-27 12:33:43 +00:00
|
|
|
command appeared in
|
|
|
|
.Bx 4.2 .
|
|
|
|
.Sh BUGS
|
2002-04-20 12:18:28 +00:00
|
|
|
The
|
|
|
|
.Nm
|
|
|
|
utility has even more switches than
|
1994-05-27 12:33:43 +00:00
|
|
|
.Xr ls 1 .
|
|
|
|
.Pp
|
|
|
|
A common mistake that often causes grief is typing:
|
|
|
|
.Pp
|
|
|
|
.Dl indent *.c
|
|
|
|
.Pp
|
|
|
|
to the shell in an attempt to indent all the
|
2002-04-20 12:18:28 +00:00
|
|
|
.Em C
|
|
|
|
programs in a directory.
|
1994-05-27 12:33:43 +00:00
|
|
|
This is probably a bug, not a feature.
|