xref: /netbsd-src/usr.bin/indent/indent.1 (revision 5187119b0ea6b00d0cfaa5618bbbcaed77c06074)
1*5187119bSrillig.\"	$NetBSD: indent.1,v 1.33 2023/06/09 06:36:57 rillig Exp $
29d225a17Stls.\"
3226284beSmrg.\" Copyright (c) 1980, 1990, 1993
4226284beSmrg.\"	The Regents of the University of California.  All rights reserved.
5d6a1bc3fSkamil.\" Copyright (c) 1976 Board of Trustees of the University of Illinois.
6d6a1bc3fSkamil.\" All rights reserved.
789aaa1bbSagc.\"
889aaa1bbSagc.\" Redistribution and use in source and binary forms, with or without
989aaa1bbSagc.\" modification, are permitted provided that the following conditions
1089aaa1bbSagc.\" are met:
1189aaa1bbSagc.\" 1. Redistributions of source code must retain the above copyright
1289aaa1bbSagc.\"    notice, this list of conditions and the following disclaimer.
1389aaa1bbSagc.\" 2. Redistributions in binary form must reproduce the above copyright
1489aaa1bbSagc.\"    notice, this list of conditions and the following disclaimer in the
1589aaa1bbSagc.\"    documentation and/or other materials provided with the distribution.
1689aaa1bbSagc.\" 3. Neither the name of the University nor the names of its contributors
1789aaa1bbSagc.\"    may be used to endorse or promote products derived from this software
1889aaa1bbSagc.\"    without specific prior written permission.
1989aaa1bbSagc.\"
2089aaa1bbSagc.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2189aaa1bbSagc.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2289aaa1bbSagc.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2389aaa1bbSagc.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2489aaa1bbSagc.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2589aaa1bbSagc.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2689aaa1bbSagc.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2789aaa1bbSagc.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2889aaa1bbSagc.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2989aaa1bbSagc.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3089aaa1bbSagc.\" SUCH DAMAGE.
3189aaa1bbSagc.\"
32d6a1bc3fSkamil.\"	@(#)indent.1	8.1 (Berkeley) 7/1/93
33d6a1bc3fSkamil.\" $FreeBSD: head/usr.bin/indent/indent.1 334944 2018-06-11 05:35:57Z pstef $
34dab5e017Scgd.\"
35*5187119bSrillig.Dd June 9, 2023
36dab5e017Scgd.Dt INDENT 1
379e44e9b5Sgarbled.Os
38dab5e017Scgd.Sh NAME
39dab5e017Scgd.Nm indent
40dab5e017Scgd.Nd indent and format C program source
41dab5e017Scgd.Sh SYNOPSIS
42990562bfSwiz.Nm
43dab5e017Scgd.Op Ar input-file Op Ar output-file
44fb3c4927Sfair.Op Fl bacc | Fl nbacc
45dab5e017Scgd.Op Fl bad | Fl nbad
46d6a1bc3fSkamil.Op Fl badp | Fl nbadp
47dab5e017Scgd.Op Fl bap | Fl nbap
48dab5e017Scgd.Op Fl bbb | Fl nbbb
49dab5e017Scgd.Op Fl \&bc | Fl nbc
50d6a1bc3fSkamil.Op Fl \&bl | Fl \&br
51d6a1bc3fSkamil.Op Fl bs | Fl nbs
52dab5e017Scgd.Op Fl c Ns Ar n
53dab5e017Scgd.Op Fl \&cd Ns Ar n
54d6a1bc3fSkamil.Bk -words
55dab5e017Scgd.Op Fl cdb | Fl ncdb
56d6a1bc3fSkamil.Ek
57dab5e017Scgd.Op Fl \&ce | Fl nce
58dab5e017Scgd.Op Fl \&ci Ns Ar n
59dab5e017Scgd.Op Fl cli Ns Ar n
60d6a1bc3fSkamil.Op Fl cs | Fl ncs
61dab5e017Scgd.Op Fl d Ns Ar n
62dab5e017Scgd.Op Fl \&di Ns Ar n
63d6a1bc3fSkamil.Op Fl dj | Fl ndj
64d6a1bc3fSkamil.Bk -words
655299bba6Sginsbach.Op Fl eei | Fl neei
66280e2f10Srillig.Op Fl ei | Fl nei
67d6a1bc3fSkamil.Ek
68d6a1bc3fSkamil.Bk -words
69d6a1bc3fSkamil.Op Fl fbs | Fl nfbs
70dab5e017Scgd.Op Fl fc1 | Fl nfc1
71d6a1bc3fSkamil.Op Fl fcb | Fl nfcb
72d6a1bc3fSkamil.Ek
73dab5e017Scgd.Op Fl i Ns Ar n
74dab5e017Scgd.Op Fl \&ip | Fl nip
75dab5e017Scgd.Op Fl l Ns Ar n
76dab5e017Scgd.Op Fl \&lc Ns Ar n
77d6a1bc3fSkamil.Op Fl \&ldi Ns Ar n
78dab5e017Scgd.Op Fl \&lp | Fl nlp
79d6a1bc3fSkamil.Op Fl \&lpl | Fl nlpl
80dab5e017Scgd.Op Fl npro
81d6a1bc3fSkamil.Op Fl P Ns Ar file
82dab5e017Scgd.Op Fl pcs | Fl npcs
83dab5e017Scgd.Op Fl psl | Fl npsl
84dab5e017Scgd.Op Fl \&sc | Fl nsc
85d6a1bc3fSkamil.Bk -words
86dab5e017Scgd.Op Fl sob | Fl nsob
87d6a1bc3fSkamil.Ek
88dab5e017Scgd.Op Fl \&st
89d6a1bc3fSkamil.Op Fl \&ta
90d6a1bc3fSkamil.Op Fl T Ns Ar typename
91d6a1bc3fSkamil.Op Fl ts Ns Ar n
92d6a1bc3fSkamil.Op Fl U Ns Ar file
93a1ff0359Smrg.Op Fl ut | Fl nut
94dab5e017Scgd.Op Fl v | Fl \&nv
95d6a1bc3fSkamil.Op Fl -version
96dab5e017Scgd.Sh DESCRIPTION
97d6a1bc3fSkamilThe
98b0486882Slukem.Nm
99d6a1bc3fSkamilutility is a
100d6a1bc3fSkamil.Em C
101fb3c4927Sfairprogram formatter.
102fb3c4927SfairIt reformats the
103d6a1bc3fSkamil.Em C
104dab5e017Scgdprogram in the
105dab5e017Scgd.Ar input-file
106fb3c4927Sfairaccording to the switches.
107d6a1bc3fSkamilThe switches which can be
108d6a1bc3fSkamilspecified are described below.
109d6a1bc3fSkamilThey may appear before or after the file
110d6a1bc3fSkamilnames.
111dab5e017Scgd.Pp
112dab5e017Scgd.Sy NOTE :
113dab5e017ScgdIf you only specify an
114dab5e017Scgd.Ar input-file ,
115dab5e017Scgdthe formatting is
116dab5e017Scgddone `in-place', that is, the formatted file is written back into
117dab5e017Scgd.Ar input-file
118dab5e017Scgdand a backup copy of
119dab5e017Scgd.Ar input-file
120fb3c4927Sfairis written in the current directory.
121fb3c4927SfairIf
122dab5e017Scgd.Ar input-file
123dab5e017Scgdis named
124dab5e017Scgd.Sq Pa /blah/blah/file ,
125dab5e017Scgdthe backup file is named
126d6a1bc3fSkamil.Sq Pa file.BAK
12795f52097Swizby default.
12895f52097SwizThe extension used for the backup file may be overridden using the
129d6a1bc3fSkamil.Ev SIMPLE_BACKUP_SUFFIX
130d6a1bc3fSkamilenvironment variable.
131dab5e017Scgd.Pp
132dab5e017ScgdIf
133dab5e017Scgd.Ar output-file
134dab5e017Scgdis specified,
135b0486882Slukem.Nm
136d6a1bc3fSkamilchecks to make sure that it is different from
137dab5e017Scgd.Ar input-file .
138dab5e017Scgd.Pp
139dab5e017ScgdThe options listed below control the formatting style imposed by
140990562bfSwiz.Nm .
141dab5e017Scgd.Bl -tag -width Op
142fb3c4927Sfair.It Fl bacc , nbacc
143fb3c4927SfairIf
144fb3c4927Sfair.Fl bacc
145fb3c4927Sfairis specified, a blank line is forced around every conditional
146fb3c4927Sfaircompilation block.
147203b7d74SfairFor example, in front of every #ifdef and after every #endif.
148fb3c4927SfairOther blank lines surrounding such blocks will be swallowed.
149fb3c4927SfairDefault:
150fb3c4927Sfair.Fl nbacc  .
151dab5e017Scgd.It Fl bad , nbad
152dab5e017ScgdIf
153dab5e017Scgd.Fl bad
154dab5e017Scgdis specified, a blank line is forced after every block of
155fb3c4927Sfairdeclarations.
156fb3c4927SfairDefault:
157dab5e017Scgd.Fl nbad .
158d6a1bc3fSkamil.It Fl badp , nbadp
159d6a1bc3fSkamilThis is vaguely similar to
160d6a1bc3fSkamil.Fl bad
161d6a1bc3fSkamilexcept that it only applies to the first set of declarations
162d6a1bc3fSkamilin a procedure (just after the first `{') and it causes a blank
163d6a1bc3fSkamilline to be generated even if there are no declarations.
164d6a1bc3fSkamilThe default is
165d6a1bc3fSkamil.Fl nbadp .
166dab5e017Scgd.It Fl bap , nbap
167dab5e017ScgdIf
168dab5e017Scgd.Fl bap
169fb3c4927Sfairis specified, a blank line is forced after every procedure body.
170fb3c4927SfairDefault:
171dab5e017Scgd.Fl nbap .
172dab5e017Scgd.It Fl bbb , nbbb
173dab5e017ScgdIf
174dab5e017Scgd.Fl bbb
175fb3c4927Sfairis specified, a blank line is forced before every block comment.
176fb3c4927SfairDefault:
177dab5e017Scgd.Fl nbbb .
178dab5e017Scgd.It Fl \&bc , nbc
179dab5e017ScgdIf
180dab5e017Scgd.Fl \&bc
181dab5e017Scgdis specified, then a newline is forced after each comma in a declaration.
182dab5e017Scgd.Fl nbc
183fb3c4927Sfairturns off this option.
184fb3c4927SfairDefault:
185d6a1bc3fSkamil.Fl \&nbc .
186d6a1bc3fSkamil.It Fl \&bl , \&br
187dab5e017ScgdSpecifying
188dab5e017Scgd.Fl \&bl
189dab5e017Scgdlines up compound statements like this:
190dab5e017Scgd.Bd -literal -offset indent
191dab5e017Scgdif (...)
192dab5e017Scgd{
193dab5e017Scgd  code
194dab5e017Scgd}
195dab5e017Scgd.Ed
196dab5e017Scgd.Pp
197dab5e017ScgdSpecifying
198dab5e017Scgd.Fl \&br
199dab5e017Scgd(the default) makes them look like this:
200dab5e017Scgd.Bd -literal -offset indent
201dab5e017Scgdif (...) {
202dab5e017Scgd  code
203dab5e017Scgd}
204dab5e017Scgd.Ed
205d6a1bc3fSkamil.It Fl bs , nbs
206d6a1bc3fSkamilWhether a blank should always be inserted after sizeof.
207d6a1bc3fSkamilThe default is
208fb3c4927Sfair.Fl nbs .
209fb3c4927Sfair.It Fl c Ns Ar n
210fb3c4927SfairThe column in which comments on code start.
211d6a1bc3fSkamilThe default is 33.
212fb3c4927Sfair.It Fl cd Ns Ar n
213fb3c4927SfairThe column in which comments on declarations start.
214fb3c4927SfairThe default
215dab5e017Scgdis for these comments to start in the same column as those on code.
216dab5e017Scgd.It Fl cdb , ncdb
217fb3c4927SfairEnables (disables) the placement of comment delimiters on blank lines.
218d6a1bc3fSkamilWith
219d6a1bc3fSkamilthis option enabled, comments look like this:
220dab5e017Scgd.Bd -literal -offset indent
221dab5e017Scgd	/*
222dab5e017Scgd	 * this is a comment
223dab5e017Scgd	 */
224dab5e017Scgd.Ed
225dab5e017Scgd.Pp
226dab5e017ScgdRather than like this:
227dab5e017Scgd.Bd -literal -offset indent
228dab5e017Scgd	/* this is a comment */
229dab5e017Scgd.Ed
230dab5e017Scgd.Pp
231dab5e017ScgdThis only affects block comments, not comments to the right of
232fb3c4927Sfaircode.
233d6a1bc3fSkamilThe default is
234dab5e017Scgd.Fl cdb .
235dab5e017Scgd.It Fl ce , nce
236d6a1bc3fSkamilEnables (disables) forcing of `else's to cuddle up to the immediately preceding
237fb3c4927Sfair`}'.
238d6a1bc3fSkamilThe default is
239dab5e017Scgd.Fl \&ce .
240dab5e017Scgd.It Fl \&ci Ns Ar n
241dab5e017ScgdSets the continuation indent to be
242dab5e017Scgd.Ar n .
243dab5e017ScgdContinuation
244dab5e017Scgdlines will be indented that far from the beginning of the first line of the
245fb3c4927Sfairstatement.
246fb3c4927SfairParenthesized expressions have extra indentation added to
247dab5e017Scgdindicate the nesting, unless
248dab5e017Scgd.Fl \&lp
249*5187119bSrilligis in effect.
250dab5e017Scgd.Fl \&ci
251dab5e017Scgddefaults to the same value as
252dab5e017Scgd.Fl i .
253dab5e017Scgd.It Fl cli Ns Ar n
254dab5e017ScgdCauses case labels to be indented
255dab5e017Scgd.Ar n
25647e95952Srilligindentation levels to the right of the containing
257dab5e017Scgd.Ic switch
258dab5e017Scgdstatement.
259dab5e017Scgd.Fl cli0.5
26047e95952Srilligcauses case labels to be indented half an indentation level.
261d6a1bc3fSkamilThe
262d6a1bc3fSkamildefault is
263dab5e017Scgd.Fl cli0 .
264d6a1bc3fSkamil.It Fl cs , ncs
265d6a1bc3fSkamilControl whether parenthesized type names in casts are followed by a space or
266d6a1bc3fSkamilnot.
267d6a1bc3fSkamilThe default is
268d6a1bc3fSkamil.Fl ncs .
269dab5e017Scgd.It Fl d Ns Ar n
270d6a1bc3fSkamilControls the placement of comments which are not to the
271d6a1bc3fSkamilright of code.
272fb3c4927SfairFor example,
273dab5e017Scgd.Fl \&d\&1
274d6a1bc3fSkamilmeans that such comments are placed one indentation level to the
275d6a1bc3fSkamilleft of code.
276fb3c4927SfairSpecifying the default
277dab5e017Scgd.Fl \&d\&0
278fb3c4927Sfairlines up these comments with the code.
279fb3c4927SfairSee the section on comment
280dab5e017Scgdindentation below.
281dab5e017Scgd.It Fl \&di Ns Ar n
282d6a1bc3fSkamilSpecifies the indentation, in character positions,
283d6a1bc3fSkamilof global variable names and all struct/union member names
284d6a1bc3fSkamilrelative to the beginning of their type declaration.
285d6a1bc3fSkamilThe default is
286dab5e017Scgd.Fl di16 .
287dab5e017Scgd.It Fl dj , ndj
288dab5e017Scgd.Fl \&dj
289dab5e017Scgdleft justifies declarations.
290dab5e017Scgd.Fl ndj
291fb3c4927Sfairindents declarations the same as code.
292d6a1bc3fSkamilThe default is
293dab5e017Scgd.Fl ndj .
294280e2f10Srillig.It Fl eei , neei
295280e2f10SrilligEnables (disables) extra indentation on continuation lines of
296280e2f10Srilligthe expression part of
297280e2f10Srillig.Ic if
298280e2f10Srilligand
299280e2f10Srillig.Ic while
300280e2f10Srilligstatements.
301280e2f10SrilligThese continuation lines will be indented one extra level.
302280e2f10SrilligThe default is
303280e2f10Srillig.Fl neei .
304dab5e017Scgd.It Fl \&ei , nei
305dab5e017ScgdEnables (disables) special
306dab5e017Scgd.Ic else-if
307fb3c4927Sfairprocessing.
308d6a1bc3fSkamilIf it is enabled, an
309dab5e017Scgd.Ic if
310dab5e017Scgdfollowing an
311dab5e017Scgd.Ic else
312dab5e017Scgdwill have the same indentation as the preceding
313dab5e017Scgd.Ic \&if
314dab5e017Scgdstatement.
315d6a1bc3fSkamilThe default is
316fb3c4927Sfair.Fl ei .
317d6a1bc3fSkamil.It Fl fbs , nfbs
318d6a1bc3fSkamilEnables (disables) splitting the function declaration and opening brace
319d6a1bc3fSkamilacross two lines.
320d6a1bc3fSkamilThe default is
321d6a1bc3fSkamil.Fl fbs .
322dab5e017Scgd.It Fl fc1 , nfc1
323dab5e017ScgdEnables (disables) the formatting of comments that start in column 1.
324dab5e017ScgdOften, comments whose leading `/' is in column 1 have been carefully
325fb3c4927Sfairhand formatted by the programmer.
326fb3c4927SfairIn such cases,
327dab5e017Scgd.Fl nfc1
328d6a1bc3fSkamilshould be
329d6a1bc3fSkamilused.
330d6a1bc3fSkamilThe default is
331dab5e017Scgd.Fl fc1 .
332d6a1bc3fSkamil.It Fl fcb , nfcb
333d6a1bc3fSkamilEnables (disables) the formatting of block comments (ones that begin
334d6a1bc3fSkamilwith `/*\\n').
335d6a1bc3fSkamilOften, block comments have been not so carefully hand formatted by the
336d6a1bc3fSkamilprogrammer, but reformatting that would just change the line breaks is not
337d6a1bc3fSkamilwanted.
338d6a1bc3fSkamilIn such cases,
339d6a1bc3fSkamil.Fl nfcb
340d6a1bc3fSkamilshould be used.
341d6a1bc3fSkamilBlock comments are then handled like box comments.
342d6a1bc3fSkamilThe default is
343d6a1bc3fSkamil.Fl fcb .
344dab5e017Scgd.It Fl i Ns Ar n
345d6a1bc3fSkamilThe number of columns for one indentation level.
346d6a1bc3fSkamilThe default is 8.
347dab5e017Scgd.It Fl \&ip , nip
348dab5e017ScgdEnables (disables) the indentation of parameter declarations from the left
349fb3c4927Sfairmargin.
350d6a1bc3fSkamilThe default is
351dab5e017Scgd.Fl \&ip .
352dab5e017Scgd.It Fl l Ns Ar n
353fb3c4927SfairMaximum length of an output line.
354d6a1bc3fSkamilThe default is 78.
355d6a1bc3fSkamil.It Fl lc Ns Ar n
356d6a1bc3fSkamilMaximum length of an output line in a block comment.
357d6a1bc3fSkamilThe default is 0, which means to limit block comment lines in accordance with
358d6a1bc3fSkamil.Fl l .
359d6a1bc3fSkamil.It Fl \&ldi Ns Ar n
360d6a1bc3fSkamilSpecifies the indentation, in character positions,
361d6a1bc3fSkamilof local variable names
362d6a1bc3fSkamilrelative to the beginning of their type declaration.
363d6a1bc3fSkamilThe default is for local variable names to be indented
364d6a1bc3fSkamilby the same amount as global ones.
365dab5e017Scgd.It Fl \&lp , nlp
366d6a1bc3fSkamilLines up code surrounded by parentheses in continuation lines.
367d6a1bc3fSkamilWith
368d6a1bc3fSkamil.Fl \&lp ,
369d6a1bc3fSkamilif a line
370d6a1bc3fSkamilhas a left paren which is not closed on that line, then continuation lines
371d6a1bc3fSkamilwill be lined up to start at the character position just after the left
372d6a1bc3fSkamilparen.
373fb3c4927SfairFor example, here is how a piece of continued code looks with
374dab5e017Scgd.Fl nlp
375dab5e017Scgdin effect:
376dab5e017Scgd.Bd -literal -offset indent
377226284beSmrgp1 = first_procedure(second_procedure(p2, p3),
378226284beSmrg\ \ third_procedure(p4, p5));
379dab5e017Scgd.Ed
380dab5e017Scgd.Pp
381dab5e017ScgdWith
382dab5e017Scgd.Fl lp
383dab5e017Scgdin effect (the default) the code looks somewhat clearer:
384dab5e017Scgd.Bd -literal -offset indent
385226284beSmrgp1\ =\ first_procedure(second_procedure(p2,\ p3),
386d6a1bc3fSkamil\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ third_procedure(p4,\ p5));
387dab5e017Scgd.Ed
388dab5e017Scgd.Pp
389dab5e017ScgdInserting two more newlines we get:
390dab5e017Scgd.Bd -literal -offset indent
391226284beSmrgp1\ =\ first_procedure(second_procedure(p2,
392226284beSmrg\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ p3),
393d6a1bc3fSkamil\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ third_procedure(p4,
394226284beSmrg\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ p5));
395dab5e017Scgd.Ed
396d6a1bc3fSkamil.It Fl \&lpl , nlpl
397d6a1bc3fSkamilWith
398d6a1bc3fSkamil.Fl \&lpl ,
399d6a1bc3fSkamilcode surrounded by parentheses in continuation lines is lined up even if it
400d6a1bc3fSkamilwould extend past the right margin.
401d6a1bc3fSkamilWith
402d6a1bc3fSkamil.Fl \&nlpl
403d6a1bc3fSkamil(the default), such a line that would extend past the right margin is moved
404d6a1bc3fSkamilleft to keep it within the margin, if that does not require placing it to
405d6a1bc3fSkamilthe left of the prevailing indentation level.
406d6a1bc3fSkamilThese switches have no effect if
407d6a1bc3fSkamil.Fl nlp
408d6a1bc3fSkamilis selected.
409dab5e017Scgd.It Fl npro
410dab5e017ScgdCauses the profile files,
411dab5e017Scgd.Sq Pa ./.indent.pro
412dab5e017Scgdand
413dab5e017Scgd.Sq Pa ~/.indent.pro ,
414dab5e017Scgdto be ignored.
415d6a1bc3fSkamil.It Fl P Ns Ar file
416d6a1bc3fSkamilRead profile from
417d6a1bc3fSkamil.Ar file .
418dab5e017Scgd.It Fl pcs , npcs
419dab5e017ScgdIf true
420dab5e017Scgd.Pq Fl pcs
421dab5e017Scgdall procedure calls will have a space inserted between
422fb3c4927Sfairthe name and the `('.
423d6a1bc3fSkamilThe default is
424dab5e017Scgd.Fl npcs .
425dab5e017Scgd.It Fl psl , npsl
426dab5e017ScgdIf true
427dab5e017Scgd.Pq Fl psl
428dab5e017Scgdthe names of procedures being defined are placed in
429fb3c4927Sfaircolumn 1 \- their types, if any, will be left on the previous lines.
430d6a1bc3fSkamilThe
431d6a1bc3fSkamildefault is
432dab5e017Scgd.Fl psl .
433dab5e017Scgd.It Fl \&sc , nsc
434dab5e017ScgdEnables (disables) the placement of asterisks (`*'s) at the left edge of all
435dab5e017Scgdcomments.
436d6a1bc3fSkamilThe default is
437fb3c4927Sfair.Fl sc .
438dab5e017Scgd.It Fl sob , nsob
439dab5e017ScgdIf
440dab5e017Scgd.Fl sob
441fb3c4927Sfairis specified, indent will swallow optional blank lines.
442d6a1bc3fSkamilYou can use this to
443d6a1bc3fSkamilget rid of blank lines after declarations.
444fb3c4927SfairDefault:
445dab5e017Scgd.Fl nsob .
446dab5e017Scgd.It Fl \&st
447dab5e017ScgdCauses
448b0486882Slukem.Nm
449d6a1bc3fSkamilto take its input from stdin and put its output to stdout.
450d6a1bc3fSkamil.It Fl ta
451d6a1bc3fSkamilAutomatically add all identifiers ending in "_t" to the list
452d6a1bc3fSkamilof type keywords.
453dab5e017Scgd.It Fl T Ns Ar typename
454dab5e017ScgdAdds
455dab5e017Scgd.Ar typename
456fb3c4927Sfairto the list of type keywords.
457fb3c4927SfairNames accumulate:
458dab5e017Scgd.Fl T
459fb3c4927Sfaircan be specified more than once.
460fb3c4927SfairYou need to specify all the typenames that
461dab5e017Scgdappear in your program that are defined by
462dab5e017Scgd.Ic typedef
463dab5e017Scgd\- nothing will be
464d6a1bc3fSkamilharmed if you miss a few, but the program will not be formatted as nicely as
465fb3c4927Sfairit should.
466d6a1bc3fSkamilThis sounds like a painful thing to have to do, but it is really
467dab5e017Scgda symptom of a problem in C:
468dab5e017Scgd.Ic typedef
469dab5e017Scgdcauses a syntactic change in the
470dab5e017Scgdlanguage and
471b0486882Slukem.Nm
472d6a1bc3fSkamilcannot find all
473dab5e017Scgdinstances of
474dab5e017Scgd.Ic typedef .
475d6a1bc3fSkamil.It Fl ts Ns Ar n
476d6a1bc3fSkamilAssumed distance between tab stops.
477d6a1bc3fSkamilThe default is 8.
478d6a1bc3fSkamil.It Fl U Ns Ar file
479d6a1bc3fSkamilAdds type names from
480d6a1bc3fSkamil.Ar file
481d6a1bc3fSkamilto the list of type keywords.
482a1ff0359Smrg.It Fl ut , nut
483a1ff0359SmrgEnables (disables) the use of tab characters in the output.
484a1ff0359SmrgThe default is
485a1ff0359Smrg.Fl ut .
486dab5e017Scgd.It Fl v , \&nv
487dab5e017Scgd.Fl v
488dab5e017Scgdturns on `verbose' mode;
489dab5e017Scgd.Fl \&nv
490fb3c4927Sfairturns it off.
491fb3c4927SfairWhen in verbose mode,
492b0486882Slukem.Nm
49324133b79Srilligreports its configuration on the standard error output.
494d6a1bc3fSkamilThe default is
495dab5e017Scgd.Fl \&nv .
496d6a1bc3fSkamil.It Fl -version
497d6a1bc3fSkamilCauses
498d6a1bc3fSkamil.Nm
499d6a1bc3fSkamilto print its version number and exit.
500dab5e017Scgd.El
501dab5e017Scgd.Pp
502dab5e017ScgdYou may set up your own `profile' of defaults to
503b0486882Slukem.Nm
504dab5e017Scgdby creating a file called
505dab5e017Scgd.Pa .indent.pro
506dab5e017Scgdin your login directory and/or the current directory and including
507fb3c4927Sfairwhatever switches you like.
508fb3c4927SfairA `.indent.pro' in the current directory takes
509fb3c4927Sfairprecedence over the one in your login directory.
510fb3c4927SfairIf
511b0486882Slukem.Nm
512dab5e017Scgdis run and a profile file exists, then it is read to set up the program's
513fb3c4927Sfairdefaults.
514d6a1bc3fSkamilSwitches on the command line, though, always override profile
515d6a1bc3fSkamilswitches.
516fb3c4927SfairThe switches should be separated by spaces, tabs or newlines.
517dab5e017Scgd.Ss Comments
518dab5e017Scgd.Sq Em Box
519dab5e017Scgd.Em comments .
520d6a1bc3fSkamilThe
521b0486882Slukem.Nm
522d6a1bc3fSkamilutility
523fb3c4927Sfairassumes that any comment with a dash or star immediately after the start of
524fb3c4927Sfaircomment (that is, `/*\-' or `/**') is a comment surrounded by a box of stars.
525fb3c4927SfairEach line of such a comment is left unchanged, except that its indentation
526fb3c4927Sfairmay be adjusted to account for the change in indentation of the first line
527dab5e017Scgdof the comment.
528dab5e017Scgd.Pp
529dab5e017Scgd.Em Straight text .
530dab5e017ScgdAll other comments are treated as straight text.
531d6a1bc3fSkamilThe
532b0486882Slukem.Nm
533d6a1bc3fSkamilutility fits as many words (separated by blanks, tabs, or newlines) on a
534fb3c4927Sfairline as possible.
535fb3c4927SfairBlank lines break paragraphs.
536dab5e017Scgd.Ss Comment indentation
537dab5e017ScgdIf a comment is on a line with code it is started in the `comment column',
538dab5e017Scgdwhich is set by the
539dab5e017Scgd.Fl c Ns Ns Ar n
540fb3c4927Sfaircommand line parameter.
541fb3c4927SfairOtherwise, the comment is started at
542dab5e017Scgd.Ar n
543dab5e017Scgdindentation levels less than where code is currently being placed, where
544dab5e017Scgd.Ar n
545dab5e017Scgdis specified by the
546dab5e017Scgd.Fl d Ns Ns Ar n
547fb3c4927Sfaircommand line parameter.
548fb3c4927SfairIf the code on a line extends past the comment
549dab5e017Scgdcolumn, the comment starts further to the right, and the right margin may be
550dab5e017Scgdautomatically extended in extreme cases.
551dab5e017Scgd.Ss Preprocessor lines
552dab5e017ScgdIn general,
553b0486882Slukem.Nm
554fb3c4927Sfairleaves preprocessor lines alone.
555fb3c4927SfairConditional compilation
556dab5e017Scgd.Pq Ic #ifdef...#endif
557dab5e017Scgdis recognized and
558b0486882Slukem.Nm
559dab5e017Scgdattempts to correctly
560dab5e017Scgdcompensate for the syntactic peculiarities introduced.
561dab5e017Scgd.Ss C syntax
562d6a1bc3fSkamilThe
563b0486882Slukem.Nm
564d6a1bc3fSkamilutility understands a substantial amount about the syntax of C, but it
565fb3c4927Sfairhas a `forgiving' parser.
566d6a1bc3fSkamilIt attempts to cope with the usual sorts of
567d6a1bc3fSkamilincomplete and malformed syntax.
568fb3c4927SfairIn particular, the use of macros like:
569dab5e017Scgd.Pp
570dab5e017Scgd.Dl #define forever for(;;)
571dab5e017Scgd.Pp
572dab5e017Scgdis handled properly.
573dab5e017Scgd.Sh ENVIRONMENT
574d6a1bc3fSkamilThe
575b0486882Slukem.Nm
576d6a1bc3fSkamilutility uses the
577dab5e017Scgd.Ev HOME
578dab5e017Scgdenvironment variable.
579dab5e017Scgd.Sh FILES
580dab5e017Scgd.Bl -tag -width "./.indent.pro" -compact
581dab5e017Scgd.It Pa ./.indent.pro
582dab5e017Scgdprofile file
583dab5e017Scgd.It Pa ~/.indent.pro
584dab5e017Scgdprofile file
585dab5e017Scgd.El
586dab5e017Scgd.Sh HISTORY
587dab5e017ScgdThe
588b0486882Slukem.Nm
589dab5e017Scgdcommand appeared in
590dab5e017Scgd.Bx 4.2 .
591dab5e017Scgd.Sh BUGS
592d6a1bc3fSkamilThe
593b0486882Slukem.Nm
594d6a1bc3fSkamilutility has even more switches than
595dab5e017Scgd.Xr ls 1 .
596dab5e017Scgd.Pp
597d6a1bc3fSkamilA common mistake is to try to indent all the
598d6a1bc3fSkamil.Em C
599d6a1bc3fSkamilprograms in a directory by typing:
600dab5e017Scgd.Pp
601dab5e017Scgd.Dl indent *.c
602dab5e017Scgd.Pp
603dab5e017ScgdThis is probably a bug, not a feature.
604