1INDENT(1)                   General Commands Manual                  INDENT(1)
2
3
4

NAME

6       indent - indent and format C program source
7

SYNOPSIS

9       indent     [    input-file   [   output-file   ]   ]   [ -bad | -nbad ]
10              [ -bap | -nbap ] [ -bbb | -nbbb ]  [ -bc | -nbc ]  [ -bl | -br ]
11              [ -cn ]   [ -cdn ]   [ -cdb | -ncdb ]   [ -ce | -nce ]  [ -cin ]
12              [ -clin ]   [ -dn ]   [ -din ]   [ -dj | -ndj ]   [ -ei | -nei ]
13              [ -fc1 | -nfc1 ]   [ -in ]   [ -ip | -nip ]   [ -ln ]   [ -lcn ]
14              [ -lp | -nlp ]   [ -npro ]    [ -pcs | -npcs ]    [ -ps | -nps ]
15              [ -psl | -npsl ]    [ -sc | -nsc ]    [ -sob | -nsob ]   [ -st ]
16              [ -troff ] [ -v | -nv ]
17

DESCRIPTION

19       Indent is a C program formatter.  It reformats the  C  program  in  the
20       input-file according to the switches.  The switches which can be speci‐
21       fied are described below. They may appear  before  or  after  the  file
22       names.
23
24       NOTE:  If  you  only specify an input-file, the formatting is done `in-
25       place', that is, the formatted file is written back into input-file and
26       a  backup  copy  of input-file is written in the current directory.  If
27       input-file  is  named  `/blah/blah/file',  the  backup  file  is  named
28       file.BAK.
29
30       If output-file is specified, indent checks to make sure it is different
31       from input-file.
32

OPTIONS

34       The options listed  below  control  the  formatting  style  imposed  by
35       indent.
36
37       -bad,-nbad     If -bad is specified, a blank line is forced after every
38                      block of declarations.  Default: -nbad.
39
40       -bap,-nbap     If -bap is specified, a blank line is forced after every
41                      procedure body.  Default: -nbap.
42
43       -bbb,-nbbb     If  -bbb  is  specified,  a  blank line is forced before
44                      every block comment.  Default: -nbbb.
45
46       -bc,-nbc       If -bc is specified, then a newline is forced after each
47                      comma  in  a  declaration.   -nbc turns off this option.
48                      The default is -nbc.
49
50       -br,-bl        Specifying -bl lines up compound statements like this:
51                          if (...)
52                          {
53                              code
54                          }
55                      Specifying -br (the default) makes them look like this:
56                          if (...) {
57                              code
58                          }
59
60       -cn            The column in which comments on code start.  The default
61                      is 33.
62
63       -cdn           The column in which comments on declarations start.  The
64                      default is for these comments to start in the same  col‐
65                      umn as those on code.
66
67       -cdb,-ncdb     Enables  (disables)  the placement of comment delimiters
68                      on blank lines.  With this option enabled, comments look
69                      like this:
70                           /*
71                            * this is a comment
72                            */
73                      Rather than like this:
74                           /* this is a comment */
75                      This  only  affects  block comments, not comments to the
76                      right of code. The default is -cdb.
77
78       -ce,-nce       Enables (disables) forcing `else's to cuddle up  to  the
79                      immediately preceding `}'.  The default is -ce.
80
81       -cin           Sets  the  continuation  indent  to  be n.  Continuation
82                      lines will be indented that far from  the  beginning  of
83                      the  first line of the statement.  Parenthesized expres‐
84                      sions have extra indentation added to indicate the nest‐
85                      ing,  unless -lp is in effect.  -ci defaults to the same
86                      value as -i.
87
88       -clin          Causes case labels to be indented n  tab  stops  to  the
89                      right  of  the  containing  switch  statement.   -cli0.5
90                      causes case labels to be indented half a tab stop.   The
91                      default is -cli0.  (This is the only option that takes a
92                      fractional argument.)
93
94       -dn            Controls the placement of comments which are not to  the
95                      right  of code.  Specifying -d1 means that such comments
96                      are placed one indentation level to the  left  of  code.
97                      The  default  -d0 lines up these comments with the code.
98                      See the section on comment indentation below.
99
100       -din           Specifies the indentation, in character positions,  from
101                      a  declaration keyword to the following identifier.  The
102                      default is -di16.
103
104       -dj,-ndj       -dj left justifies declarations.  -ndj indents  declara‐
105                      tions the same as code.  The default is -ndj.
106
107       -ei,-nei       Enables   (disables)  special  else-if  processing.   If
108                      enabled, ifs following elses will have the same indenta‐
109                      tion as the preceding if statement.  The default is -ei.
110
111       -fc1,-nfc1     Enables (disables) the formatting of comments that start
112                      in column 1.  Often, comments whose leading  `/'  is  in
113                      column  1 have been carefully hand formatted by the pro‐
114                      grammer.  In such cases,  -nfc1  should  be  used.   The
115                      default is -fc1.
116
117       -in            The  number  of  spaces  for one indentation level.  The
118                      default is 8.
119
120       -ip,-nip       Enables (disables) the indentation of parameter declara‐
121                      tions from the left margin.  The default is -ip.
122
123       -ln            Maximum length of an output line.  The default is 78.
124
125       -lp,-nlp       Lines  up code surrounded by parenthesis in continuation
126                      lines.  If a line has a left paren which is  not  closed
127                      on  that  line, then continuation lines will be lined up
128                      to start at the character position just after  the  left
129                      paren.   For  example,  here is how a piece of continued
130                      code looks with -nlp in effect:
131                          p1 = first_procedure(second_procedure(p2, p3),
132                              third_procedure(p4, p5));
133                      With -lp in effect (the default) the code looks somewhat
134                      clearer:
135                          p1 = first_procedure(second_procedure(p2, p3),
136                                               third_procedure(p4, p5));
137                      Inserting two more newlines we get:
138                          p1 = first_procedure(second_procedure(p2,
139                                                                p3),
140                                               third_procedure(p4,
141                                                               p5));
142
143       -npro          Causes    the   profile   files,   `./.indent.pro'   and
144                      `~/.indent.pro', to be ignored.
145
146       -pcs,-npcs     If true (-pcs) all procedure calls  will  have  a  space
147                      inserted  between  the name and the `('.  The default is
148                      -npcs.
149
150       -ps,-nps       If true (-ps) the pointer following operator  `->'  will
151                      be  surrounded by spaces on either side.  The default is
152                      -nps.
153
154       -psl,-npsl     If true (-psl) the names of procedures being defined are
155                      placed  in  column 1 - their types, if any, will be left
156                      on the previous lines.  The default is -psl.
157
158       -sc,-nsc       Enables (disables) the placement of asterisks (`*'s)  at
159                      the left edge of all comments.  The default is -sc.
160
161       -sob,-nsob     If -sob is specified, indent will swallow optional blank
162                      lines.  You can use this to get rid of blank lines after
163                      declarations.  Default: -nsob.
164
165       -st            Causes  indent to take its input from stdin, and put its
166                      output to stdout.
167
168       -Ttypename     Adds typename to the list of type keywords.  Names accu‐
169                      mulate: -T can be specified more than once.  You need to
170                      specify all the typenames that appear  in  your  program
171                      that are defined by typedefs - nothing will be harmed if
172                      you miss a few, but the program won't  be  formatted  as
173                      nicely  as  it should.  This sounds like a painful thing
174                      to have to do, but it's really a symptom of a problem in
175                      C: typedef causes a syntactic change in the language and
176                      indent can't find all typedefs.
177
178       -troff         Causes indent to format the program  for  processing  by
179                      troff.  It will produce a fancy listing in much the same
180                      spirit as vgrind.  If the output file is not  specified,
181                      the  default  is standard output, rather than formatting
182                      in place.
183
184       -v,-nv         -v turns on `verbose' mode; -nv turns it off.   When  in
185                      verbose  mode, indent reports when it splits one line of
186                      input into two or more lines of output, and  gives  some
187                      size statistics at completion. The default is -nv.
188

FURTHER DESCRIPTION

190       You  may  set up your own `profile' of defaults to indent by creating a
191       file called .indent.pro in either your login directory and/or the  cur‐
192       rent  directory  and including whatever switches you like.  Switches in
193       `.indent.pro' in the current directory override  those  in  your  login
194       directory  (with the exception of -T type definitions, which just accu‐
195       mulate).  If indent is run and a profile file exists, then it  is  read
196       to  set up the program's defaults.  The switches should be separated by
197       spaces, tabs or newlines.  Switches on the command line, however, over‐
198       ride profile switches.
199
200       Comments
201
202       `Box'  comments.   Indent  assumes that any comment with a dash or star
203       immediately after the start of comment (that is, `/*-' or `/**')  is  a
204       comment  surrounded  by a box of stars.  Each line of such a comment is
205       left unchanged, except that its indentation may be adjusted to  account
206       for the change in indentation of the first line of the comment.
207
208       Straight  text.   All  other  comments  are  treated  as straight text.
209       Indent fits as many words (separated by blanks, tabs, or newlines) on a
210       line as possible.  Blank lines break paragraphs.
211
212       Comment indentation
213
214       If  a comment is on a line with code it is started in the `comment col‐
215       umn', which is set by the -cn command line parameter.   Otherwise,  the
216       comment is started at n indentation levels less than where code is cur‐
217       rently being placed, where n is  specified  by  the  -dn  command  line
218       parameter.   If the code on a line extends past the comment column, the
219       comment starts further to the right, and the right margin may be  auto‐
220       matically extended in extreme cases.
221
222       Preprocessor lines
223
224       In general, indent leaves preprocessor lines alone.  The only reformat‐
225       ting that it will do is to straighten up trailing comments.  It  leaves
226       embedded  comments alone.  Conditional compilation (#ifdef...#endif) is
227       recognized and indent attempts to correctly compensate for the  syntac‐
228       tic peculiarities introduced.
229
230       C syntax
231
232       Indent  understands  a substantial amount about the syntax of C, but it
233       has a `forgiving' parser.  It attempts to cope with the usual sorts  of
234       incomplete  and  misformed  syntax.   In  particular, the use of macros
235       like:
236               #define forever for(;;)
237       is handled properly.
238

FILES

240       ./.indent.pro  profile file
241       ~/.indent.pro  profile file
242

BUGS

244       Indent has even more switches than ls.
245
246       A common mistake that often causes grief is typing:
247           indent *.c
248       to the shell in an attempt to indent all the C programs in a directory.
249       This is probably a bug, not a feature.
250
251
252
2534.2 Berkeley Distribution     September 10, 1985                     INDENT(1)
Impressum