xref: /minix3/usr.bin/indent/indent.1 (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1*0a6a1f1dSLionel Sambuc.\"	$NetBSD: indent.1,v 1.23 2014/09/04 04:06:07 mrg Exp $
297c7d358SVivek Prakash.\"
397c7d358SVivek Prakash.\" Copyright (c) 1980, 1990, 1993
497c7d358SVivek Prakash.\"	The Regents of the University of California.  All rights reserved.
597c7d358SVivek Prakash.\"
697c7d358SVivek Prakash.\" Redistribution and use in source and binary forms, with or without
797c7d358SVivek Prakash.\" modification, are permitted provided that the following conditions
897c7d358SVivek Prakash.\" are met:
997c7d358SVivek Prakash.\" 1. Redistributions of source code must retain the above copyright
1097c7d358SVivek Prakash.\"    notice, this list of conditions and the following disclaimer.
1197c7d358SVivek Prakash.\" 2. Redistributions in binary form must reproduce the above copyright
1297c7d358SVivek Prakash.\"    notice, this list of conditions and the following disclaimer in the
1397c7d358SVivek Prakash.\"    documentation and/or other materials provided with the distribution.
1497c7d358SVivek Prakash.\" 3. Neither the name of the University nor the names of its contributors
1597c7d358SVivek Prakash.\"    may be used to endorse or promote products derived from this software
1697c7d358SVivek Prakash.\"    without specific prior written permission.
1797c7d358SVivek Prakash.\"
1897c7d358SVivek Prakash.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
1997c7d358SVivek Prakash.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2097c7d358SVivek Prakash.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2197c7d358SVivek Prakash.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2297c7d358SVivek Prakash.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2397c7d358SVivek Prakash.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2497c7d358SVivek Prakash.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2597c7d358SVivek Prakash.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2697c7d358SVivek Prakash.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2797c7d358SVivek Prakash.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2897c7d358SVivek Prakash.\" SUCH DAMAGE.
2997c7d358SVivek Prakash.\"
3097c7d358SVivek Prakash.\" Copyright (c) 1985 Sun Microsystems, Inc.
3197c7d358SVivek Prakash.\" Copyright (c) 1976 Board of Trustees of the University of Illinois.
3297c7d358SVivek Prakash.\" All rights reserved.
3397c7d358SVivek Prakash.\"
3497c7d358SVivek Prakash.\" Redistribution and use in source and binary forms, with or without
3597c7d358SVivek Prakash.\" modification, are permitted provided that the following conditions
3697c7d358SVivek Prakash.\" are met:
3797c7d358SVivek Prakash.\" 1. Redistributions of source code must retain the above copyright
3897c7d358SVivek Prakash.\"    notice, this list of conditions and the following disclaimer.
3997c7d358SVivek Prakash.\" 2. Redistributions in binary form must reproduce the above copyright
4097c7d358SVivek Prakash.\"    notice, this list of conditions and the following disclaimer in the
4197c7d358SVivek Prakash.\"    documentation and/or other materials provided with the distribution.
4297c7d358SVivek Prakash.\" 3. All advertising materials mentioning features or use of this software
4397c7d358SVivek Prakash.\"    must display the following acknowledgement:
4497c7d358SVivek Prakash.\"	This product includes software developed by the University of
4597c7d358SVivek Prakash.\"	California, Berkeley and its contributors.
4697c7d358SVivek Prakash.\" 4. Neither the name of the University nor the names of its contributors
4797c7d358SVivek Prakash.\"    may be used to endorse or promote products derived from this software
4897c7d358SVivek Prakash.\"    without specific prior written permission.
4997c7d358SVivek Prakash.\"
5097c7d358SVivek Prakash.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
5197c7d358SVivek Prakash.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5297c7d358SVivek Prakash.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5397c7d358SVivek Prakash.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
5497c7d358SVivek Prakash.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5597c7d358SVivek Prakash.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
5697c7d358SVivek Prakash.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
5797c7d358SVivek Prakash.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
5897c7d358SVivek Prakash.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
5997c7d358SVivek Prakash.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
6097c7d358SVivek Prakash.\" SUCH DAMAGE.
6197c7d358SVivek Prakash.\"
6297c7d358SVivek Prakash.\"	from: @(#)indent.1	8.1 (Berkeley) 7/1/93
6397c7d358SVivek Prakash.\"
64*0a6a1f1dSLionel Sambuc.Dd September 2, 2014
6597c7d358SVivek Prakash.Dt INDENT 1
6697c7d358SVivek Prakash.Os
6797c7d358SVivek Prakash.Sh NAME
6897c7d358SVivek Prakash.Nm indent
6997c7d358SVivek Prakash.Nd indent and format C program source
7097c7d358SVivek Prakash.Sh SYNOPSIS
7197c7d358SVivek Prakash.Nm
7297c7d358SVivek Prakash.Op Ar input-file Op Ar output-file
7397c7d358SVivek Prakash.Op Fl bacc | Fl nbacc
7497c7d358SVivek Prakash.Op Fl bad | Fl nbad
7597c7d358SVivek Prakash.Op Fl bap | Fl nbap
7697c7d358SVivek Prakash.Op Fl bbb | Fl nbbb
7797c7d358SVivek Prakash.Op Fl \&bc | Fl nbc
7897c7d358SVivek Prakash.Op Fl \&bl
7997c7d358SVivek Prakash.Op Fl \&br
8097c7d358SVivek Prakash.Op Fl c Ns Ar n
8197c7d358SVivek Prakash.Op Fl \&cd Ns Ar n
8297c7d358SVivek Prakash.Op Fl cdb | Fl ncdb
8397c7d358SVivek Prakash.Op Fl \&ce | Fl nce
8497c7d358SVivek Prakash.Op Fl \&ci Ns Ar n
8597c7d358SVivek Prakash.Op Fl cli Ns Ar n
8697c7d358SVivek Prakash.Op Fl d Ns Ar n
8797c7d358SVivek Prakash.Op Fl \&di Ns Ar n
8897c7d358SVivek Prakash.Op Fl fc1 | Fl nfc1
8997c7d358SVivek Prakash.Op Fl i Ns Ar n
9097c7d358SVivek Prakash.Op Fl \&ip | Fl nip
9197c7d358SVivek Prakash.Op Fl l Ns Ar n
9297c7d358SVivek Prakash.Op Fl \&lc Ns Ar n
9397c7d358SVivek Prakash.Op Fl \&lp | Fl nlp
9497c7d358SVivek Prakash.Op Fl npro
9597c7d358SVivek Prakash.Op Fl pcs | Fl npcs
9697c7d358SVivek Prakash.Op Fl psl | Fl npsl
9797c7d358SVivek Prakash.Op Fl \&sc | Fl nsc
9897c7d358SVivek Prakash.Op Fl sob | Fl nsob
9997c7d358SVivek Prakash.Op Fl \&st
10097c7d358SVivek Prakash.Op Fl troff
101*0a6a1f1dSLionel Sambuc.Op Fl ut | Fl nut
10297c7d358SVivek Prakash.Op Fl v | Fl \&nv
10397c7d358SVivek Prakash.Sh DESCRIPTION
10497c7d358SVivek Prakash.Nm
10597c7d358SVivek Prakashis a
10697c7d358SVivek Prakash.Tn C
10797c7d358SVivek Prakashprogram formatter.
10897c7d358SVivek PrakashIt reformats the
10997c7d358SVivek Prakash.Tn C
11097c7d358SVivek Prakashprogram in the
11197c7d358SVivek Prakash.Ar input-file
11297c7d358SVivek Prakashaccording to the switches.
11397c7d358SVivek PrakashThe switches which can be specified are described below.
11497c7d358SVivek PrakashThey may appear before or after the file names.
11597c7d358SVivek Prakash.Pp
11697c7d358SVivek Prakash.Sy NOTE  :
11797c7d358SVivek PrakashIf you only specify an
11897c7d358SVivek Prakash.Ar input-file  ,
11997c7d358SVivek Prakashthe formatting is
12097c7d358SVivek Prakashdone `in-place', that is, the formatted file is written back into
12197c7d358SVivek Prakash.Ar input-file
12297c7d358SVivek Prakashand a backup copy of
12397c7d358SVivek Prakash.Ar input-file
12497c7d358SVivek Prakashis written in the current directory.
12597c7d358SVivek PrakashIf
12697c7d358SVivek Prakash.Ar input-file
12797c7d358SVivek Prakashis named
12897c7d358SVivek Prakash.Sq Pa /blah/blah/file ,
12997c7d358SVivek Prakashthe backup file is named
13097c7d358SVivek Prakash.Pa file.BAK .
13197c7d358SVivek Prakash.Pp
13297c7d358SVivek PrakashIf
13397c7d358SVivek Prakash.Ar output-file
13497c7d358SVivek Prakashis specified,
13597c7d358SVivek Prakash.Nm
13697c7d358SVivek Prakashchecks to make sure it is different from
13797c7d358SVivek Prakash.Ar input-file  .
13897c7d358SVivek Prakash.Pp
139*0a6a1f1dSLionel SambucIf no
140*0a6a1f1dSLionel Sambuc.Ar input-file
141*0a6a1f1dSLionel Sambucis specified
142*0a6a1f1dSLionel Sambucinput is read from stdin and the formatted file is written to stdout.
143*0a6a1f1dSLionel Sambuc.Pp
14497c7d358SVivek PrakashThe options listed below control the formatting style imposed by
14597c7d358SVivek Prakash.Nm  .
14697c7d358SVivek Prakash.Bl -tag -width Op
14797c7d358SVivek Prakash.It Fl bacc , nbacc
14897c7d358SVivek PrakashIf
14997c7d358SVivek Prakash.Fl bacc
15097c7d358SVivek Prakashis specified, a blank line is forced around every conditional
15197c7d358SVivek Prakashcompilation block.
15297c7d358SVivek PrakashFor example, in front of every #ifdef and after every #endif.
15397c7d358SVivek PrakashOther blank lines surrounding such blocks will be swallowed.
15497c7d358SVivek PrakashDefault:
15597c7d358SVivek Prakash.Fl nbacc  .
15697c7d358SVivek Prakash.It Fl bad , nbad
15797c7d358SVivek PrakashIf
15897c7d358SVivek Prakash.Fl bad
15997c7d358SVivek Prakashis specified, a blank line is forced after every block of
16097c7d358SVivek Prakashdeclarations.
16197c7d358SVivek PrakashDefault:
16297c7d358SVivek Prakash.Fl nbad  .
16397c7d358SVivek Prakash.It Fl bap , nbap
16497c7d358SVivek PrakashIf
16597c7d358SVivek Prakash.Fl bap
16697c7d358SVivek Prakashis specified, a blank line is forced after every procedure body.
16797c7d358SVivek PrakashDefault:
16897c7d358SVivek Prakash.Fl nbap  .
16997c7d358SVivek Prakash.It Fl bbb , nbbb
17097c7d358SVivek PrakashIf
17197c7d358SVivek Prakash.Fl bbb
17297c7d358SVivek Prakashis specified, a blank line is forced before every block comment.
17397c7d358SVivek PrakashDefault:
17497c7d358SVivek Prakash.Fl nbbb  .
17597c7d358SVivek Prakash.It Fl \&bc , nbc
17697c7d358SVivek PrakashIf
17797c7d358SVivek Prakash.Fl \&bc
17897c7d358SVivek Prakashis specified, then a newline is forced after each comma in a declaration.
17997c7d358SVivek Prakash.Fl nbc
18097c7d358SVivek Prakashturns off this option.
18197c7d358SVivek PrakashDefault:
18297c7d358SVivek Prakash.Fl \&bc  .
18397c7d358SVivek Prakash.It Fl \&br , \&bl
18497c7d358SVivek PrakashSpecifying
18597c7d358SVivek Prakash.Fl \&bl
18697c7d358SVivek Prakashlines up compound statements like this:
18797c7d358SVivek Prakash.Bd -literal -offset indent
18897c7d358SVivek Prakashif (...)
18997c7d358SVivek Prakash{
19097c7d358SVivek Prakash  code
19197c7d358SVivek Prakash}
19297c7d358SVivek Prakash.Ed
19397c7d358SVivek Prakash.Pp
19497c7d358SVivek PrakashSpecifying
19597c7d358SVivek Prakash.Fl \&br
19697c7d358SVivek Prakash(the default) makes them look like this:
19797c7d358SVivek Prakash.Bd -literal -offset indent
19897c7d358SVivek Prakashif (...) {
19997c7d358SVivek Prakash  code
20097c7d358SVivek Prakash}
20197c7d358SVivek Prakash.Ed
20297c7d358SVivek Prakash.It Fl bs , Fl nbs
20397c7d358SVivek PrakashIf
20497c7d358SVivek Prakash.Fl bs
20597c7d358SVivek Prakashis specified, a blank is forced after
20697c7d358SVivek Prakash.Ic sizeof .
20797c7d358SVivek PrakashDefault:
20897c7d358SVivek Prakash.Fl nbs  .
20997c7d358SVivek Prakash.It Fl c Ns Ar n
21097c7d358SVivek PrakashThe column in which comments on code start.
21197c7d358SVivek PrakashDefault:
21297c7d358SVivek Prakash.Fl c33  .
21397c7d358SVivek Prakash.It Fl cd Ns Ar n
21497c7d358SVivek PrakashThe column in which comments on declarations start.
21597c7d358SVivek PrakashThe default
21697c7d358SVivek Prakashis for these comments to start in the same column as those on code.
21797c7d358SVivek Prakash.It Fl cdb , ncdb
21897c7d358SVivek PrakashEnables (disables) the placement of comment delimiters on blank lines.
21997c7d358SVivek PrakashWith this option enabled, comments look like this:
22097c7d358SVivek Prakash.Bd -literal -offset indent
22197c7d358SVivek Prakash	/*
22297c7d358SVivek Prakash	 * this is a comment
22397c7d358SVivek Prakash	 */
22497c7d358SVivek Prakash.Ed
22597c7d358SVivek Prakash.Pp
22697c7d358SVivek PrakashRather than like this:
22797c7d358SVivek Prakash.Bd -literal -offset indent
22897c7d358SVivek Prakash	/* this is a comment */
22997c7d358SVivek Prakash.Ed
23097c7d358SVivek Prakash.Pp
23197c7d358SVivek PrakashThis only affects block comments, not comments to the right of
23297c7d358SVivek Prakashcode.
23397c7d358SVivek PrakashDefault:
23497c7d358SVivek Prakash.Fl cdb  .
23597c7d358SVivek Prakash.It Fl ce , nce
23697c7d358SVivek PrakashEnables (disables) forcing `else's to cuddle up to the immediately preceding
23797c7d358SVivek Prakash`}'.
23897c7d358SVivek PrakashDefault:
23997c7d358SVivek Prakash.Fl \&ce  .
24097c7d358SVivek Prakash.It Fl \&ci Ns Ar n
24197c7d358SVivek PrakashSets the continuation indent to be
24297c7d358SVivek Prakash.Ar n  .
24397c7d358SVivek PrakashContinuation
24497c7d358SVivek Prakashlines will be indented that far from the beginning of the first line of the
24597c7d358SVivek Prakashstatement.
24697c7d358SVivek PrakashParenthesized expressions have extra indentation added to
24797c7d358SVivek Prakashindicate the nesting, unless
24897c7d358SVivek Prakash.Fl \&lp
24997c7d358SVivek Prakashis in effect.
25097c7d358SVivek Prakash.Fl \&ci
25197c7d358SVivek Prakashdefaults to the same value as
25297c7d358SVivek Prakash.Fl i  .
25397c7d358SVivek Prakash.It Fl cli Ns Ar n
25497c7d358SVivek PrakashCauses case labels to be indented
25597c7d358SVivek Prakash.Ar n
25697c7d358SVivek Prakashtab stops to the right of the containing
25797c7d358SVivek Prakash.Ic switch
25897c7d358SVivek Prakashstatement.
25997c7d358SVivek Prakash.Fl cli0.5
26097c7d358SVivek Prakashcauses case labels to be indented half a tab stop.
26197c7d358SVivek PrakashDefault:
26297c7d358SVivek Prakash.Fl cli0  .
26397c7d358SVivek Prakash.It Fl d Ns Ar n
26497c7d358SVivek PrakashControls the placement of comments which are not to the right of code.
26597c7d358SVivek PrakashFor example,
26697c7d358SVivek Prakash.Fl \&d\&1
26797c7d358SVivek Prakashmeans that such comments are placed one indentation level to the left of code.
26897c7d358SVivek PrakashSpecifying the default
26997c7d358SVivek Prakash.Fl \&d\&0
27097c7d358SVivek Prakashlines up these comments with the code.
27197c7d358SVivek PrakashSee the section on comment
27297c7d358SVivek Prakashindentation below.
27397c7d358SVivek Prakash.It Fl \&di Ns Ar n
27497c7d358SVivek PrakashSpecifies the indentation, in character positions, from a declaration keyword
27597c7d358SVivek Prakashto the following identifier.
27697c7d358SVivek PrakashDefault:
27797c7d358SVivek Prakash.Fl di16  .
27897c7d358SVivek Prakash.It Fl dj , ndj
27997c7d358SVivek Prakash.Fl \&dj
28097c7d358SVivek Prakashleft justifies declarations.
28197c7d358SVivek Prakash.Fl ndj
28297c7d358SVivek Prakashindents declarations the same as code.
28397c7d358SVivek PrakashDefault:
28497c7d358SVivek Prakash.Fl ndj  .
28597c7d358SVivek Prakash.It Fl \&ei , nei
28697c7d358SVivek PrakashEnables (disables) special
28797c7d358SVivek Prakash.Ic else-if
28897c7d358SVivek Prakashprocessing.
28997c7d358SVivek PrakashIf it's enabled, an
29097c7d358SVivek Prakash.Ic if
29197c7d358SVivek Prakashfollowing an
29297c7d358SVivek Prakash.Ic else
29397c7d358SVivek Prakashwill have the same indentation as the preceding
29497c7d358SVivek Prakash.Ic \&if
29597c7d358SVivek Prakashstatement.
29697c7d358SVivek PrakashDefault:
29797c7d358SVivek Prakash.Fl ei  .
29897c7d358SVivek Prakash.It Fl eei , neei
29997c7d358SVivek PrakashEnables (disables) extra indentation on continuation lines of
30097c7d358SVivek Prakashthe expression part of
30197c7d358SVivek Prakash.Ic if
30297c7d358SVivek Prakashand
30397c7d358SVivek Prakash.Ic while
30497c7d358SVivek Prakashstatements.
30597c7d358SVivek PrakashThese continuation lines will be indented one extra level.
30697c7d358SVivek PrakashDefault:
30797c7d358SVivek Prakash.Fl neei  .
30897c7d358SVivek Prakash.It Fl fc1 , nfc1
30997c7d358SVivek PrakashEnables (disables) the formatting of comments that start in column 1.
31097c7d358SVivek PrakashOften, comments whose leading `/' is in column 1 have been carefully
31197c7d358SVivek Prakashhand formatted by the programmer.
31297c7d358SVivek PrakashIn such cases,
31397c7d358SVivek Prakash.Fl nfc1
31497c7d358SVivek Prakashshould be used.
31597c7d358SVivek PrakashDefault:
31697c7d358SVivek Prakash.Fl fc1  .
31797c7d358SVivek Prakash.It Fl i Ns Ar n
31897c7d358SVivek PrakashThe number of spaces for one indentation level.
31997c7d358SVivek PrakashDefault:
32097c7d358SVivek Prakash.Fl i8 .
32197c7d358SVivek Prakash.It Fl \&ip , nip
32297c7d358SVivek PrakashEnables (disables) the indentation of parameter declarations from the left
32397c7d358SVivek Prakashmargin.
32497c7d358SVivek PrakashDefault:
32597c7d358SVivek Prakash.Fl \&ip  .
32697c7d358SVivek Prakash.It Fl l Ns Ar n
32797c7d358SVivek PrakashMaximum length of an output line.
32897c7d358SVivek PrakashDefault:
32997c7d358SVivek Prakash.Fl l78  .
33097c7d358SVivek Prakash.It Fl \&lp , nlp
33197c7d358SVivek PrakashLines up code surrounded by parenthesis in continuation lines.
33297c7d358SVivek PrakashIf a line has a left parenthesis which is not closed on that line, then
33397c7d358SVivek Prakashcontinuation lines will be lined up to start at the character
33497c7d358SVivek Prakashposition just after the left parenthesis.
33597c7d358SVivek PrakashFor example, here is how a piece of continued code looks with
33697c7d358SVivek Prakash.Fl nlp
33797c7d358SVivek Prakashin effect:
33897c7d358SVivek Prakash.Bd -literal -offset indent
33997c7d358SVivek Prakashp1 = first_procedure(second_procedure(p2, p3),
34097c7d358SVivek Prakash\ \ third_procedure(p4,p5));
34197c7d358SVivek Prakash.Ed
34297c7d358SVivek Prakash.Pp
34397c7d358SVivek PrakashWith
34497c7d358SVivek Prakash.Fl lp
34597c7d358SVivek Prakashin effect (the default) the code looks somewhat clearer:
34697c7d358SVivek Prakash.Bd -literal -offset indent
34797c7d358SVivek Prakashp1\ =\ first_procedure(second_procedure(p2,\ p3),
34897c7d358SVivek Prakash\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ third_procedure(p4,p5));
34997c7d358SVivek Prakash.Ed
35097c7d358SVivek Prakash.Pp
35197c7d358SVivek PrakashInserting two more newlines we get:
35297c7d358SVivek Prakash.Bd -literal -offset indent
35397c7d358SVivek Prakashp1\ =\ first_procedure(second_procedure(p2,
35497c7d358SVivek Prakash\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ p3),
35597c7d358SVivek Prakash\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ third_procedure(p4
35697c7d358SVivek Prakash\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ p5));
35797c7d358SVivek Prakash.Ed
35897c7d358SVivek Prakash.It Fl npro
35997c7d358SVivek PrakashCauses the profile files,
36097c7d358SVivek Prakash.Sq Pa ./.indent.pro
36197c7d358SVivek Prakashand
36297c7d358SVivek Prakash.Sq Pa ~/.indent.pro ,
36397c7d358SVivek Prakashto be ignored.
36497c7d358SVivek Prakash.It Fl pcs , npcs
36597c7d358SVivek PrakashIf true
36697c7d358SVivek Prakash.Pq Fl pcs
36797c7d358SVivek Prakashall procedure calls will have a space inserted between
36897c7d358SVivek Prakashthe name and the `('.
36997c7d358SVivek PrakashDefault:
37097c7d358SVivek Prakash.Fl npcs  .
37197c7d358SVivek Prakash.It Fl psl , npsl
37297c7d358SVivek PrakashIf true
37397c7d358SVivek Prakash.Pq Fl psl
37497c7d358SVivek Prakashthe names of procedures being defined are placed in
37597c7d358SVivek Prakashcolumn 1 \- their types, if any, will be left on the previous lines.
37697c7d358SVivek PrakashDefault:
37797c7d358SVivek Prakash.Fl psl  .
37897c7d358SVivek Prakash.It Fl \&sc , nsc
37997c7d358SVivek PrakashEnables (disables) the placement of asterisks (`*'s) at the left edge of all
38097c7d358SVivek Prakashcomments.
38197c7d358SVivek PrakashDefault:
38297c7d358SVivek Prakash.Fl sc  .
38397c7d358SVivek Prakash.It Fl sob , nsob
38497c7d358SVivek PrakashIf
38597c7d358SVivek Prakash.Fl sob
38697c7d358SVivek Prakashis specified, indent will swallow optional blank lines.
38797c7d358SVivek PrakashYou can use this to get rid of blank lines after declarations.
38897c7d358SVivek PrakashDefault:
38997c7d358SVivek Prakash.Fl nsob  .
39097c7d358SVivek Prakash.It Fl \&st
39197c7d358SVivek PrakashCauses
39297c7d358SVivek Prakash.Nm
39397c7d358SVivek Prakashto take its input from stdin, and put its output to stdout.
39497c7d358SVivek Prakash.It Fl T Ns Ar typename
39597c7d358SVivek PrakashAdds
39697c7d358SVivek Prakash.Ar typename
39797c7d358SVivek Prakashto the list of type keywords.
39897c7d358SVivek PrakashNames accumulate:
39997c7d358SVivek Prakash.Fl T
40097c7d358SVivek Prakashcan be specified more than once.
40197c7d358SVivek PrakashYou need to specify all the typenames that
40297c7d358SVivek Prakashappear in your program that are defined by
40397c7d358SVivek Prakash.Ic typedef
40497c7d358SVivek Prakash\- nothing will be
40597c7d358SVivek Prakashharmed if you miss a few, but the program won't be formatted as nicely as
40697c7d358SVivek Prakashit should.
40797c7d358SVivek PrakashThis sounds like a painful thing to have to do, but it's really
40897c7d358SVivek Prakasha symptom of a problem in C:
40997c7d358SVivek Prakash.Ic typedef
41097c7d358SVivek Prakashcauses a syntactic change in the
41197c7d358SVivek Prakashlanguage and
41297c7d358SVivek Prakash.Nm
41397c7d358SVivek Prakashcan't find all
41497c7d358SVivek Prakashinstances of
41597c7d358SVivek Prakash.Ic typedef .
41697c7d358SVivek Prakash.It Fl troff
41797c7d358SVivek PrakashCauses
41897c7d358SVivek Prakash.Nm
41997c7d358SVivek Prakashto format the program for processing by
42097c7d358SVivek Prakash.Xr troff 1 .
42197c7d358SVivek PrakashIt will produce a fancy
42297c7d358SVivek Prakashlisting in much the same spirit as
42397c7d358SVivek Prakash.Xr vgrind 1 .
42497c7d358SVivek PrakashIf the output file is not specified, the default is standard output,
42597c7d358SVivek Prakashrather than formatting in place.
426*0a6a1f1dSLionel Sambuc.It Fl ut , nut
427*0a6a1f1dSLionel SambucEnables (disables) the use of tab characters in the output.
428*0a6a1f1dSLionel SambucTabs are assumed to be aligned on columns divisible by 8.
429*0a6a1f1dSLionel SambucThe default is
430*0a6a1f1dSLionel Sambuc.Fl ut .
43197c7d358SVivek Prakash.It Fl v , \&nv
43297c7d358SVivek Prakash.Fl v
43397c7d358SVivek Prakashturns on `verbose' mode;
43497c7d358SVivek Prakash.Fl \&nv
43597c7d358SVivek Prakashturns it off.
43697c7d358SVivek PrakashWhen in verbose mode,
43797c7d358SVivek Prakash.Nm
43897c7d358SVivek Prakashreports when it splits one line of input into two or more lines of output,
43997c7d358SVivek Prakashand gives some size statistics at completion.
44097c7d358SVivek PrakashDefault:
44197c7d358SVivek Prakash.Fl \&nv  .
44297c7d358SVivek Prakash.El
44397c7d358SVivek Prakash.Pp
44497c7d358SVivek PrakashYou may set up your own `profile' of defaults to
44597c7d358SVivek Prakash.Nm
44697c7d358SVivek Prakashby creating a file called
44797c7d358SVivek Prakash.Pa .indent.pro
44897c7d358SVivek Prakashin your login directory and/or the current directory and including
44997c7d358SVivek Prakashwhatever switches you like.
45097c7d358SVivek PrakashA `.indent.pro' in the current directory takes
45197c7d358SVivek Prakashprecedence over the one in your login directory.
45297c7d358SVivek PrakashIf
45397c7d358SVivek Prakash.Nm
45497c7d358SVivek Prakashis run and a profile file exists, then it is read to set up the program's
45597c7d358SVivek Prakashdefaults.
45697c7d358SVivek PrakashSwitches on the command line, though, always override profile switches.
45797c7d358SVivek PrakashThe switches should be separated by spaces, tabs or newlines.
45897c7d358SVivek Prakash.Ss Comments
45997c7d358SVivek Prakash.Sq Em Box
46097c7d358SVivek Prakash.Em comments .
46197c7d358SVivek Prakash.Nm
46297c7d358SVivek Prakashassumes that any comment with a dash or star immediately after the start of
46397c7d358SVivek Prakashcomment (that is, `/*\-' or `/**') is a comment surrounded by a box of stars.
46497c7d358SVivek PrakashEach line of such a comment is left unchanged, except that its indentation
46597c7d358SVivek Prakashmay be adjusted to account for the change in indentation of the first line
46697c7d358SVivek Prakashof the comment.
46797c7d358SVivek Prakash.Pp
46897c7d358SVivek Prakash.Em Straight text .
46997c7d358SVivek PrakashAll other comments are treated as straight text.
47097c7d358SVivek Prakash.Nm
47197c7d358SVivek Prakashfits as many words (separated by blanks, tabs, or newlines) on a
47297c7d358SVivek Prakashline as possible.
47397c7d358SVivek PrakashBlank lines break paragraphs.
47497c7d358SVivek Prakash.Ss Comment indentation
47597c7d358SVivek PrakashIf a comment is on a line with code it is started in the `comment column',
47697c7d358SVivek Prakashwhich is set by the
47797c7d358SVivek Prakash.Fl c Ns Ns Ar n
47897c7d358SVivek Prakashcommand line parameter.
47997c7d358SVivek PrakashOtherwise, the comment is started at
48097c7d358SVivek Prakash.Ar n
48197c7d358SVivek Prakashindentation levels less than where code is currently being placed, where
48297c7d358SVivek Prakash.Ar n
48397c7d358SVivek Prakashis specified by the
48497c7d358SVivek Prakash.Fl d Ns Ns Ar n
48597c7d358SVivek Prakashcommand line parameter.
48697c7d358SVivek PrakashIf the code on a line extends past the comment
48797c7d358SVivek Prakashcolumn, the comment starts further to the right, and the right margin may be
48897c7d358SVivek Prakashautomatically extended in extreme cases.
48997c7d358SVivek Prakash.Ss Preprocessor lines
49097c7d358SVivek PrakashIn general,
49197c7d358SVivek Prakash.Nm
49297c7d358SVivek Prakashleaves preprocessor lines alone.
49397c7d358SVivek PrakashThe only reformatting that it will do is to straighten up trailing comments.
49497c7d358SVivek PrakashIt leaves embedded comments alone.
49597c7d358SVivek PrakashConditional compilation
49697c7d358SVivek Prakash.Pq Ic #ifdef...#endif
49797c7d358SVivek Prakashis recognized and
49897c7d358SVivek Prakash.Nm
49997c7d358SVivek Prakashattempts to correctly
50097c7d358SVivek Prakashcompensate for the syntactic peculiarities introduced.
50197c7d358SVivek Prakash.Ss C syntax
50297c7d358SVivek Prakash.Nm
50397c7d358SVivek Prakashunderstands a substantial amount about the syntax of C, but it
50497c7d358SVivek Prakashhas a `forgiving' parser.
50597c7d358SVivek PrakashIt attempts to cope with the usual sorts of incomplete and misformed syntax.
50697c7d358SVivek PrakashIn particular, the use of macros like:
50797c7d358SVivek Prakash.Pp
50897c7d358SVivek Prakash.Dl #define forever for(;;)
50997c7d358SVivek Prakash.Pp
51097c7d358SVivek Prakashis handled properly.
51197c7d358SVivek Prakash.Sh ENVIRONMENT
51297c7d358SVivek Prakash.Nm
51397c7d358SVivek Prakashuses the
51497c7d358SVivek Prakash.Ev HOME
51597c7d358SVivek Prakashenvironment variable.
51697c7d358SVivek Prakash.Sh FILES
51797c7d358SVivek Prakash.Bl -tag -width "./.indent.pro" -compact
51897c7d358SVivek Prakash.It Pa ./.indent.pro
51997c7d358SVivek Prakashprofile file
52097c7d358SVivek Prakash.It Pa ~/.indent.pro
52197c7d358SVivek Prakashprofile file
52297c7d358SVivek Prakash.El
52397c7d358SVivek Prakash.Sh HISTORY
52497c7d358SVivek PrakashThe
52597c7d358SVivek Prakash.Nm
52697c7d358SVivek Prakashcommand appeared in
52797c7d358SVivek Prakash.Bx 4.2 .
52897c7d358SVivek Prakash.Sh BUGS
52997c7d358SVivek Prakash.Nm
53097c7d358SVivek Prakashhas even more switches than
53197c7d358SVivek Prakash.Xr ls 1 .
53297c7d358SVivek Prakash.Pp
53397c7d358SVivek PrakashA common mistake that often causes grief is typing:
53497c7d358SVivek Prakash.Pp
53597c7d358SVivek Prakash.Dl indent *.c
53697c7d358SVivek Prakash.Pp
53797c7d358SVivek Prakashto the shell in an attempt to indent all the
53897c7d358SVivek Prakash.Tn C
53997c7d358SVivek Prakashprograms in a directory.
54097c7d358SVivek PrakashThis is probably a bug, not a feature.
541