~ubuntu-branches/ubuntu/trusty/indent/trusty

« back to all changes in this revision

Viewing changes to man/indent.1

  • Committer: Bazaar Package Importer
  • Author(s): Santiago Vila
  • Date: 2002-01-27 18:47:28 UTC
  • Revision ID: james.westby@ubuntu.com-20020127184728-5w6lnpj072bqil91
Tags: upstream-2.2.7
ImportĀ upstreamĀ versionĀ 2.2.7

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
.TH INDENT 1L 
 
2
.SH "NAME"
 
3
indent \- changes the appearance of a C program by inserting or deleting whitespace.  
 
4
.SH "SYNOPSIS"
 
5
.B "indent "
 
6
[options] [input\-files]
 
7
.sp
 
8
.B "indent "
 
9
[options] [single\-input\-file] [\-o output\-file]
 
10
.sp
 
11
.B "indent "
 
12
\-\-version
 
13
.SH "DESCRIPTION"
 
14
This man page is generated from the file \fIindent.texinfo\fR.
 
15
This is Edition  of "The \fBindent\fR Manual",
 
16
for Indent Version , last updated .
 
17
 
 
18
The \fBindent\fR program
 
19
can be used to make code easier to read.  It can also convert from one
 
20
style of writing C to another.  
 
21
 
 
22
.B indent\fR understands a substantial amount about the syntax of C,
 
23
but it also attempts to cope with incomplete and misformed syntax.
 
24
 
 
25
In version 1.2 and more recent versions, the GNU style of indenting is
 
26
the default.
 
27
.SH "OPTIONS"
 
28
 
 
29
.TP 4
 
30
.B -bad\fR, \fB--blank-lines-after-declarations\fR
 
31
Force blank lines after the declarations.
 
32
.br
 
33
See \fB\ BLANK\ LINES\fR.
 
34
.TP
 
35
.B -bap\fR, \fB--blank-lines-after-procedures\fR
 
36
Force blank lines after procedure bodies.
 
37
.br
 
38
See \fB\ BLANK\ LINES\fR.
 
39
.TP
 
40
.B -bbb\fR, \fB--blank-lines-before-block-comments\fR
 
41
Force blank lines before block comments.
 
42
.br
 
43
See \fB\ BLANK\ LINES\fR.
 
44
.TP
 
45
.B -bbo\fR, \fB--break-before-boolean-operator\fR
 
46
Prefer to break long lines before boolean operators.
 
47
.br
 
48
See \fB\ BREAKING\ LONG\ LINES\fR.
 
49
.TP
 
50
.B -bc\fR, \fB--blank-lines-after-commas\fR
 
51
Force newline after comma in declaration.
 
52
.br
 
53
See \fB\ DECLARATIONS\fR.
 
54
.TP
 
55
.B -bl\fR, \fB--braces-after-if-line\fR
 
56
Put braces on line after \fBif\fR, etc.
 
57
.br
 
58
See \fB\ STATEMENTS\fR.
 
59
.TP
 
60
.B -bli\fIn\fB\fR, \fB--brace-indent\fIn\fB\fR
 
61
Indent braces \fIn\fR spaces.
 
62
.br
 
63
See \fB\ STATEMENTS\fR.
 
64
.TP
 
65
.B -bls\fR, \fB--braces-after-struct-decl-line\fR
 
66
Put braces on the line after \fBstruct\fR declaration lines.
 
67
.br
 
68
See \fB\ DECLARATIONS\fR.
 
69
.TP
 
70
.B -br\fR, \fB--braces-on-if-line\fR
 
71
Put braces on line with \fBif\fR, etc.
 
72
.br
 
73
See \fB\ STATEMENTS\fR.
 
74
.TP
 
75
.B -brs\fR, \fB--braces-on-struct-decl-line\fR
 
76
Put braces on \fBstruct\fR declaration line.
 
77
.br
 
78
See \fB\ DECLARATIONS\fR.
 
79
.TP
 
80
.B -bs\fR, \fB--Bill-Shannon\fR, \fB--blank-before-sizeof\fR
 
81
Put a space between \fBsizeof\fR and its argument.
 
82
.br
 
83
See \fB\ STATEMENTS\fR.
 
84
.TP
 
85
.B -c\fIn\fB\fR, \fB--comment-indentation\fIn\fB\fR
 
86
Put comments to the right of code in column \fIn\fR.
 
87
.br
 
88
See \fB\ COMMENTS\fR.
 
89
.TP
 
90
.B -cbi\fIn\fB\fR, \fB--case-brace-indentation\fIn\fB\fR
 
91
Indent braces after a case label N spaces.
 
92
.br
 
93
See \fB\ STATEMENTS\fR.
 
94
.TP
 
95
.B -cd\fIn\fB\fR, \fB--declaration-comment-column\fIn\fB\fR
 
96
Put comments to the right of the declarations in column \fIn\fR.
 
97
.br
 
98
See \fB\ COMMENTS\fR.
 
99
.TP
 
100
.B -cdb\fR, \fB--comment-delimiters-on-blank-lines\fR
 
101
Put comment delimiters on blank lines.
 
102
.br
 
103
See \fB\ COMMENTS\fR.
 
104
.TP
 
105
.B -cdw\fR, \fB--cuddle-do-while\fR
 
106
Cuddle while of \fBdo {} while;\fR and preceeding \`}\'.
 
107
.br
 
108
See \fB\ COMMENTS\fR.
 
109
.TP
 
110
.B -ce\fR, \fB--cuddle-else\fR
 
111
Cuddle else and preceeding \`}\'.
 
112
.br
 
113
See \fB\ COMMENTS\fR.
 
114
.TP
 
115
.B -ci\fIn\fB\fR, \fB--continuation-indentation\fIn\fB\fR
 
116
Continuation indent of \fIn\fR spaces.
 
117
.br
 
118
See \fB\ STATEMENTS\fR.
 
119
.TP
 
120
.B -cli\fIn\fB\fR, \fB--case-indentation\fIn\fB\fR
 
121
Case label indent of \fIn\fR spaces.
 
122
.br
 
123
See \fB\ STATEMENTS\fR.
 
124
.TP
 
125
.B -cp\fIn\fB\fR, \fB--else-endif-column\fIn\fB\fR
 
126
Put comments to the right of \fB#else\fR and \fB
 
127
#endif\fR statements in column \fIn\fR.
 
128
.br
 
129
See \fB\ COMMENTS\fR.
 
130
.TP
 
131
.B -cs\fR, \fB--space-after-cast\fR
 
132
Put a space after a cast operator.
 
133
.br
 
134
See \fB\ STATEMENTS\fR.
 
135
.TP
 
136
.B -d\fIn\fB\fR, \fB--line-comments-indentation\fIn\fB\fR
 
137
Set indentation of comments not to the right 
 
138
of code to \fIn\fR spaces.
 
139
.br
 
140
See \fB\ COMMENTS\fR.
 
141
.TP
 
142
.B -bfda\fR, \fB--break-function-decl-args\fR
 
143
Align all arguments in a declaration with opening paren.
 
144
.br
 
145
See \fB\ DECLARATIONS\fR.
 
146
.TP
 
147
.B -di\fIn\fB\fR, \fB--declaration-indentation\fIn\fB\fR
 
148
Put variables in column \fIn\fR.
 
149
.br
 
150
See \fB\ DECLARATIONS\fR.
 
151
.TP
 
152
.B -fc1\fR, \fB--format-first-column-comments\fR
 
153
Format comments in the first column.
 
154
.br
 
155
See \fB\ COMMENTS\fR.
 
156
.TP
 
157
.B -fca\fR, \fB--format-all-comments\fR
 
158
Do not disable all formatting of comments.
 
159
.br
 
160
See \fB\ COMMENTS\fR.
 
161
.TP
 
162
.B -gnu\fR, \fB--gnu-style\fR
 
163
Use GNU coding style.  This is the default.
 
164
.br
 
165
See \fB\ COMMON\ STYLES\fR.
 
166
.TP
 
167
.B -hnl\fR, \fB--honour-newlines\fR
 
168
Prefer to break long lines at the position of newlines in the input.
 
169
.br
 
170
See \fB\ BREAKING\ LONG\ LINES\fR.
 
171
.TP
 
172
.B -i\fIn\fB\fR, \fB--indent-level\fIn\fB\fR
 
173
Set indentation level to \fIn\fR spaces.
 
174
.br
 
175
See \fB\ INDENTATION\fR.
 
176
.TP
 
177
.B -ip\fIn\fB\fR, \fB--parameter-indentation\fIn\fB\fR
 
178
Indent parameter types in old-style function 
 
179
definitions by \fIn\fR spaces.
 
180
.br
 
181
See \fB\ INDENTATION\fR.
 
182
.TP
 
183
.B -kr\fR, \fB--k-and-r-style\fR
 
184
Use Kernighan & Ritchie coding style.
 
185
.br
 
186
See \fB\ COMMON\ STYLES\fR.
 
187
.TP
 
188
.B -l\fIn\fB\fR, \fB--line-length\fIn\fB\fR
 
189
Set maximum line length for non-comment lines to \fIn\fR.
 
190
.br
 
191
See \fB\ BREAKING\ LONG\ LINES\fR.
 
192
.TP
 
193
.B -lc\fIn\fB\fR, \fB--comment-line-length\fIn\fB\fR
 
194
Set maximum line length for comment formatting to \fIn\fR.
 
195
.br
 
196
See \fB\ COMMENTS\fR.
 
197
.TP
 
198
.B -lp\fR, \fB--continue-at-parentheses\fR
 
199
Line up continued lines at parentheses.
 
200
.br
 
201
See \fB\ INDENTATION\fR.
 
202
.TP
 
203
.B -lps\fR, \fB--leave-preprocessor-space\fR
 
204
Leave space between \`#\' and preprocessor directive.
 
205
.br
 
206
See \fB\ INDENTATION\fR.
 
207
.TP
 
208
.B -nbad\fR, \fB--no-blank-lines-after-declarations\fR
 
209
Do not force blank lines after declarations.
 
210
.br
 
211
See \fB\ BLANK\ LINES\fR.
 
212
.TP
 
213
.B -nbap\fR, \fB--no-blank-lines-after-procedures\fR
 
214
Do not force blank lines after procedure bodies.
 
215
.br
 
216
See \fB\ BLANK\ LINES\fR.
 
217
.TP
 
218
.B -nbbo\fR, \fB--break-after-boolean-operator\fR
 
219
Do not prefer to break long lines before boolean operators.
 
220
.br
 
221
See \fB\ BREAKING\ LONG\ LINES\fR.
 
222
.TP
 
223
.B -nbc\fR, \fB--no-blank-lines-after-commas\fR
 
224
Do not force newlines after commas in declarations.
 
225
.br
 
226
See \fB\ DECLARATIONS\fR.
 
227
.TP
 
228
.B -nbfda\fR, \fB--dont-break-function-decl-args\fR
 
229
Don\'t put each argument in a function declaration on a seperate line.
 
230
.br
 
231
See \fB\ DECLARATIONS\fR.
 
232
.TP
 
233
.B -ncdb\fR, \fB--no-comment-delimiters-on-blank-lines\fR
 
234
Do not put comment delimiters on blank lines.
 
235
.br
 
236
See \fB\ COMMENTS\fR.
 
237
.TP
 
238
.B -ncdw\fR, \fB--dont-cuddle-do-while\fR
 
239
Do not cuddle \fB}\fR and the \fBwhile\fR of a \fBdo {} while;\fR.
 
240
.br
 
241
See \fB\ STATEMENTS\fR.
 
242
.TP
 
243
.B -nce\fR, \fB--dont-cuddle-else\fR
 
244
Do not cuddle \fB}\fR and \fBelse\fR.
 
245
.br
 
246
See \fB\ STATEMENTS\fR.
 
247
.TP
 
248
.B -ncs\fR, \fB--no-space-after-casts\fR
 
249
Do not put a space after cast operators.
 
250
.br
 
251
See \fB\ STATEMENTS\fR.
 
252
.TP
 
253
.B -nfc1\fR, \fB--dont-format-first-column-comments\fR
 
254
Do not format comments in the first column as normal.
 
255
.br
 
256
See \fB\ COMMENTS\fR.
 
257
.TP
 
258
.B -nfca\fR, \fB--dont-format-comments\fR
 
259
Do not format any comments.
 
260
.br
 
261
See \fB\ COMMENTS\fR.
 
262
.TP
 
263
.B -nhnl\fR, \fB--ignore-newlines\fR
 
264
Do not prefer to break long lines at the position of newlines in the input.
 
265
.br
 
266
See \fB\ BREAKING\ LONG\ LINES\fR.
 
267
.TP
 
268
.B -nip\fR, \fB--no-parameter-indentation\fR
 
269
Zero width indentation for parameters.
 
270
.br
 
271
See \fB\ INDENTATION\fR.
 
272
.TP
 
273
.B -nlp\fR, \fB--dont-line-up-parentheses\fR
 
274
Do not line up parentheses.
 
275
.br
 
276
See \fB\ STATEMENTS\fR.
 
277
.TP
 
278
.B -npcs\fR, \fB--no-space-after-function-call-names\fR
 
279
Do not put space after the function in function calls.
 
280
.br
 
281
See \fB\ STATEMENTS\fR.
 
282
.TP
 
283
.B -nprs\fR, \fB--no-space-after-parentheses\fR
 
284
Do not put a space after every \'(\' and before every \')\'.
 
285
.br
 
286
See \fB\ STATEMENTS\fR.
 
287
.TP
 
288
.B -npsl\fR, \fB--dont-break-procedure-type\fR
 
289
Put the type of a procedure on the same line as its name.
 
290
.br
 
291
See \fB\ DECLARATIONS\fR.
 
292
.TP
 
293
.B -nsaf\fR, \fB--no-space-after-for\fR
 
294
Do not put a space after every \fBfor\fR.
 
295
.br
 
296
See \fB\ STATEMENTS\fR.
 
297
.TP
 
298
.B -nsai\fR, \fB--no-space-after-if\fR
 
299
Do not put a space after every \fBif\fR.
 
300
.br
 
301
See \fB\ STATEMENTS\fR.
 
302
.TP
 
303
.B -nsaw\fR, \fB--no-space-after-while\fR
 
304
Do not put a space after every \fBwhile\fR.
 
305
.br
 
306
See \fB\ STATEMENTS\fR.
 
307
.TP
 
308
.B -nsc\fR, \fB--dont-star-comments\fR
 
309
Do not put the \`*\' character at the left of comments.
 
310
.br
 
311
See \fB\ COMMENTS\fR.
 
312
.TP
 
313
.B -nsob\fR, \fB--leave-optional-blank-lines\fR
 
314
Do not swallow optional blank lines.
 
315
.br
 
316
See \fB\ BLANK\ LINES\fR.
 
317
.TP
 
318
.B -nss\fR, \fB--dont-space-special-semicolon\fR
 
319
Do not force a space before the semicolon after certain statements.
 
320
Disables \`-ss\'.
 
321
.br
 
322
See \fB\ STATEMENTS\fR.
 
323
.TP
 
324
.B -nut\fR, \fB--no-tabs\fR
 
325
Use spaces instead of tabs.
 
326
.br
 
327
See \fB\ INDENTATION\fR.
 
328
.TP
 
329
.B -nv\fR, \fB--no-verbosity\fR
 
330
Disable verbose mode.
 
331
.br
 
332
See \fB\ MISCELLANEOUS\ OPTIONS\fR.
 
333
.TP
 
334
.B -orig\fR, \fB--original\fR
 
335
Use the original Berkeley coding style.
 
336
.br
 
337
See \fB\ COMMON\ STYLES\fR.
 
338
.TP
 
339
.B -npro\fR, \fB--ignore-profile\fR
 
340
Do not read \`.indent.pro\' files.
 
341
.br
 
342
See \fB\ INVOKING\ INDENT\fR.
 
343
.TP
 
344
.B -pcs\fR, \fB--space-after-procedure-calls\fR
 
345
Insert a space between the name of the 
 
346
procedure being called and the \`(\'.
 
347
.br
 
348
See \fB\ STATEMENTS\fR.
 
349
.TP
 
350
.B -pi\fIn\fB\fR, \fB--paren-indentation\fIn\fB\fR
 
351
Specify the extra indentation per open parentheses \'(\' when a
 
352
statement is broken.See \fB\ STATEMENTS\fR.
 
353
.TP
 
354
.B -pmt\fR, \fB--preserve-mtime\fR
 
355
Preserve access and modification times on output files.See \fB\ MISCELLANEOUS\ OPTIONS\fR.
 
356
.TP
 
357
.B -prs\fR, \fB--space-after-parentheses\fR
 
358
Put a space after every \'(\' and before every \')\'.
 
359
.br
 
360
See \fB\ STATEMENTS\fR.
 
361
.TP
 
362
.B -psl\fR, \fB--procnames-start-lines\fR
 
363
Put the type of a procedure on the line before its name.
 
364
.br
 
365
See \fB\ DECLARATIONS\fR.
 
366
.TP
 
367
.B -saf\fR, \fB--space-after-for\fR
 
368
Put a space after each \fBfor\fR.
 
369
.br
 
370
See \fB\ STATEMENTS\fR.
 
371
.TP
 
372
.B -sai\fR, \fB--space-after-if\fR
 
373
Put a space after each \fBif\fR.
 
374
.br
 
375
See \fB\ STATEMENTS\fR.
 
376
.TP
 
377
.B -saw\fR, \fB--space-after-while\fR
 
378
Put a space after each \fBwhile\fR.
 
379
.br
 
380
See \fB\ STATEMENTS\fR.
 
381
.TP
 
382
.B -sbi\fIn\fB\fR, \fB--struct-brace-indentation\fIn\fB\fR
 
383
Indent braces of a struct, union or enum N spaces.
 
384
.br
 
385
See \fB\ STATEMENTS\fR.
 
386
.TP
 
387
.B -sc\fR, \fB--start-left-side-of-comments\fR
 
388
Put the \`*\' character at the left of comments.
 
389
.br
 
390
See \fB\ COMMENTS\fR.
 
391
.TP
 
392
.B -sob\fR, \fB--swallow-optional-blank-lines\fR
 
393
Swallow optional blank lines.
 
394
.br
 
395
See \fB\ BLANK\ LINES\fR.
 
396
.TP
 
397
.B -ss\fR, \fB--space-special-semicolon\fR
 
398
On one-line \fBfor\fR and \fBwhile\fR statments, 
 
399
force a blank before the semicolon.
 
400
.br
 
401
See \fB\ STATEMENTS\fR.
 
402
.TP
 
403
.B -st\fR, \fB--standard-output\fR
 
404
Write to standard output.
 
405
.br
 
406
See \fB\ INVOKING\ INDENT\fR.
 
407
.TP
 
408
.B -T\fR
 
409
Tell \fBindent\fR the name of typenames.
 
410
.br
 
411
See \fB\ DECLARATIONS\fR.
 
412
.TP
 
413
.B -ts\fIn\fB\fR, \fB--tab-size\fIn\fB\fR
 
414
Set tab size to \fIn\fR spaces.
 
415
.br
 
416
See \fB\ INDENTATION\fR.
 
417
.TP
 
418
.B -ut\fR, \fB--use-tabs\fR
 
419
Use tabs. This is the default.
 
420
.br
 
421
See \fB\ INDENTATION\fR.
 
422
.TP
 
423
.B -v\fR, \fB--verbose\fR
 
424
Enable verbose mode.
 
425
.br
 
426
See \fB\ MISCELLANEOUS\ OPTIONS\fR.
 
427
.TP
 
428
.B -version\fR
 
429
Output the version number of \fBindent\fR.
 
430
.br
 
431
See \fB\ MISCELLANEOUS\ OPTIONS\fR.
 
432
 
 
433
.SH "INVOKING INDENT"
 
434
 
 
435
As of version 1.3, the format of the \fBindent\fR command is:
 
436
 
 
437
.in +5
 
438
.nf
 
439
.na
 
440
 
 
441
indent [\fIoptions\fR] [\fIinput-files\fR]
 
442
 
 
443
indent [\fIoptions\fR] [\fIsingle-input-file\fR] [-o \fIoutput-file\fR]
 
444
 
 
445
.in -5
 
446
.ad
 
447
.fi
 
448
 
 
449
This format is different from earlier versions and other versions of
 
450
.B indent\fR.
 
451
 
 
452
In the first form, one or more input files are specified.  \fBindent\fR
 
453
makes a backup copy of each file, and the original file is replaced with
 
454
its indented version.  See \fBBACKUP\ FILES\fR, for an explanation of how
 
455
backups are made.
 
456
 
 
457
In the second form, only one input file is specified.  In this case, or
 
458
when the standard input is used, you may specify an output file after
 
459
the \`-o\' option.
 
460
 
 
461
To cause \fBindent\fR to write to standard output, use the \`-st\'
 
462
option.  This is only allowed when there is only one input file, or when
 
463
the standard input is used.
 
464
 
 
465
If no input files are named, the standard input is read for input.
 
466
Also, if a filename named \`-\' is specified, then the standard input
 
467
is read.
 
468
 
 
469
As an example, each of the following commands will input the program
 
470
\`slithy_toves.c\' and write its indented text to
 
471
\`slithy_toves.out\':
 
472
 
 
473
.in +5
 
474
.nf
 
475
.na
 
476
 
 
477
indent slithy_toves.c -o slithy_toves.out
 
478
 
 
479
indent -st slithy_toves.c > slithy_toves.out
 
480
 
 
481
cat slithy_toves.c | indent -o slithy_toves.out
 
482
 
 
483
.in -5
 
484
.ad
 
485
.fi
 
486
 
 
487
Most other options to \fBindent\fR control how programs are formatted.
 
488
As of version 1.2, \fBindent\fR also recognizes a long name for each
 
489
option name.  Long options are prefixed by either \`--\' or
 
490
\`+\'.
 
491
[ \`+\' is being superseded by \`--\' to
 
492
maintain consistency with the POSIX standard.]
 
493
 In most of this document,
 
494
the traditional, short names are used for the sake of brevity.
 
495
See \fBOPTION\ SUMMARY\fR, for a list of options, including both long and
 
496
short names.
 
497
 
 
498
Here is another example:
 
499
 
 
500
.in +5
 
501
.nf
 
502
.na
 
503
indent -br test/metabolism.c -l85
 
504
.in -5
 
505
.ad
 
506
.fi
 
507
 
 
508
This will indent the program \`test/metabolism.c\' using the
 
509
\`-br\' and \`-l85\' options, write the output back to
 
510
\`test/metabolism.c\', and write the original contents of
 
511
\`test/metabolism.c\' to a backup file in the directory \`test\'.
 
512
 
 
513
Equivalent invocations using long option names for this example would
 
514
be:
 
515
 
 
516
.in +5
 
517
.nf
 
518
.na
 
519
 
 
520
indent --braces-on-if-line --line-length185 test/metabolism.c
 
521
 
 
522
indent +braces-on-if-line +line-length185 test/metabolism.c
 
523
 
 
524
.in -5
 
525
.ad
 
526
.fi
 
527
 
 
528
If you find that you often use \fBindent\fR with the same options, you
 
529
may put those options into a file named \`.indent.pro\'.
 
530
.B indent\fR will first look for \`.indent.pro\' in the current
 
531
directory and use that if found.  Otherwise, \fBindent\fR will search
 
532
your home directory for \`.indent.pro\' and use that file if it is
 
533
found.  This behaviour is different from that of other versions of
 
534
.B indent\fR, which load both files if they both exist.
 
535
 
 
536
The format of \`.indent.pro\' is simply a list of options, just as
 
537
they would appear on the command line, separated by white space (tabs,
 
538
spaces, and newlines).  Options in \`.indent.pro\' may be surrounded by C
 
539
or C++ comments, in which case they are ignored.
 
540
 
 
541
Command line switches are handled \fIafter\fR processing
 
542
\`.indent.pro\'.  Options specified later override arguments
 
543
specified earlier, with one exception: Explicitly specified options
 
544
always override background options (See \fBCOMMON\ STYLES\fR).  You can
 
545
prevent \fBindent\fR from reading an \`.indent.pro\' file by
 
546
specifying the \`-npro\' option.
 
547
 
 
548
.SH "BACKUP FILES"
 
549
 
 
550
As of version 1.3, GNU \fBindent\fR makes GNU-style backup files, the
 
551
same way GNU Emacs does.  This means that either \fIsimple\fR or
 
552
.I numbered\fR backup filenames may be made.
 
553
 
 
554
Simple backup file names are generated by appending a suffix to the
 
555
original file name.  The default for this suffix is the
 
556
one-character string \`~\' (tilde).  Thus, the backup file for
 
557
\`python.c\' would be \`python.c~\'.
 
558
 
 
559
Instead of the default, you may specify any string as a suffix by
 
560
setting the environment variable \fBSIMPLE_BACKUP_SUFFIX\fR to
 
561
your preferred suffix.
 
562
 
 
563
Numbered backup versions of a file \`momeraths.c\' look like
 
564
\`momeraths.c.~23~\', where 23 is the version of this particular
 
565
backup.  When making a numbered backup of the file \`src/momeraths.c\',
 
566
the backup file will be named \`src/momeraths.c.~\fIV\fR~\', where
 
567
.I V\fR is one greater than the highest version currently existing in
 
568
the directory \`src\'.  The environment variable \fBVERSION_WIDTH\fR
 
569
controls the number of digits, using left zero padding when necessary.
 
570
For instance, setting this variable to "2" will lead to the backup
 
571
file being named \`momeraths.c.~04~\'.
 
572
 
 
573
The type of backup file made is controlled by the value of the
 
574
environment variable \fBVERSION_CONTROL\fR.  If it is the string
 
575
\`simple\', then only simple backups will be made.  If its value is
 
576
the string \`numbered\', then numbered backups will be made.  If its
 
577
value is \`numbered-existing\', then numbered backups will be made if
 
578
there \fIalready exist\fR numbered backups for the file being indented;
 
579
otherwise, a simple backup is made.  If \fBVERSION_CONTROL\fR is not
 
580
set, then \fBindent\fR assumes the behaviour of
 
581
\`numbered-existing\'.
 
582
 
 
583
Other versions of \fBindent\fR use the suffix \`.BAK\' in naming
 
584
backup files.  This behaviour can be emulated by setting
 
585
.B SIMPLE_BACKUP_SUFFIX\fR to \`.BAK\'.
 
586
 
 
587
Note also that other versions of \fBindent\fR make backups in the
 
588
current directory, rather than in the directory of the source file as
 
589
GNU \fBindent\fR now does.
 
590
 
 
591
.SH "COMMON STYLES"
 
592
 
 
593
There are several common styles of C code, including the GNU style, the
 
594
Kernighan & Ritchie style, and the original Berkeley style.  A style may
 
595
be selected with a single \fIbackground\fR option, which specifies a set
 
596
of values for all other options.  However, explicitly specified options
 
597
always override options implied by a background option.
 
598
 
 
599
As of version 1.2, the default style of GNU \fBindent\fR is the GNU
 
600
style.  Thus, it is no longer necessary to specify the option
 
601
\`-gnu\' to obtain this format, although doing so will not cause an
 
602
error.  Option settings which correspond to the GNU style are:
 
603
 
 
604
.in +5
 
605
.nf
 
606
.na
 
607
-nbad -bap -nbc -bbo -bl -bli2 -bls -ncdb -nce -cp1 -cs -di2
 
608
-ndj -nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -nprs -psl -saf -sai
 
609
-saw -nsc -nsob
 
610
.in -5
 
611
.ad
 
612
.fi
 
613
 
 
614
The GNU coding style is that preferred by the GNU project.  It is the
 
615
style that the GNU Emacs C mode encourages and which is used in the C
 
616
portions of GNU Emacs.  (People interested in writing programs for
 
617
Project GNU should get a copy of "The GNU Coding Standards", which
 
618
also covers semantic and portability issues such as memory usage, the
 
619
size of integers, etc.)
 
620
 
 
621
The Kernighan & Ritchie style is used throughout their well-known book
 
622
"The C Programming Language".  It is enabled with the \`-kr\'
 
623
option.  The Kernighan & Ritchie style corresponds to the following set
 
624
of options:
 
625
 
 
626
.in +5
 
627
.nf
 
628
.na
 
629
-nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0
 
630
-cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs
 
631
-nprs -npsl -saf -sai -saw -nsc -nsob -nss
 
632
.in -5
 
633
.ad
 
634
.fi
 
635
 
 
636
Kernighan & Ritchie style does not put comments to the right of code in
 
637
the same column at all times (nor does it use only one space to the
 
638
right of the code), so for this style \fBindent\fR has arbitrarily
 
639
chosen column 33.
 
640
 
 
641
The style of the original Berkeley \fBindent\fR may be obtained by
 
642
specifying \`-orig\' (or by specifying \`--original\', using the
 
643
long option name).  This style is equivalent to the following settings:
 
644
 
 
645
.in +5
 
646
.nf
 
647
.na
 
648
-nbad -nbap -bbo -bc -br -brs -c33 -cd33 -cdb -ce -ci4 -cli0
 
649
-cp33 -di16 -fc1 -fca -hnl -i4 -ip4 -l75 -lp -npcs -nprs -psl
 
650
-saf -sai -saw -sc -nsob -nss -ts8
 
651
.in -5
 
652
.ad
 
653
.fi
 
654
 
 
655
.SH "BLANK LINES"
 
656
 
 
657
Various programming styles use blank lines in different places.
 
658
.B indent\fR has a number of options to insert or delete blank lines in
 
659
specific places.
 
660
 
 
661
The \`-bad\' option causes \fBindent\fR to force a blank line after
 
662
every block of declarations.  The \`-nbad\' option causes
 
663
.B indent\fR not to force such blank lines.
 
664
 
 
665
The \`-bap\' option forces a blank line after every procedure body.
 
666
The \`-nbap\' option forces no such blank line.
 
667
 
 
668
The \`-bbb\' option forces a blank line before every boxed comment
 
669
(See \fBCOMMENTS\fR.)
 
670
The \`-nbbb\' option does not force such blank lines.
 
671
 
 
672
The \`-sob\' option causes \fBindent\fR to swallow optional blank
 
673
lines (that is, any optional blank lines present in the input will be
 
674
removed from the output).  If the \`-nsob\' is specified, any blank
 
675
lines present in the input file will be copied to the output file.
 
676
 
 
677
 
 
678
.SH "--blank-lines-after-declarations"
 
679
 
 
680
The \`-bad\' option forces a blank line after every block of
 
681
declarations.  The \`-nbad\' option does not add any such blank
 
682
lines.
 
683
 
 
684
For example, given the input
 
685
.in +5
 
686
.nf
 
687
.na
 
688
char *foo;
 
689
char *bar;
 
690
/* This separates blocks of declarations.  */
 
691
int baz;
 
692
.in -5
 
693
.ad
 
694
.fi
 
695
 
 
696
.B indent -bad\fR produces
 
697
 
 
698
.in +5
 
699
.nf
 
700
.na
 
701
char *foo;
 
702
char *bar;
 
703
 
 
704
/* This separates blocks of declarations.  */
 
705
int baz;
 
706
.in -5
 
707
.ad
 
708
.fi
 
709
 
 
710
and \fBindent -nbad\fR produces
 
711
 
 
712
.in +5
 
713
.nf
 
714
.na
 
715
char *foo;
 
716
char *bar;
 
717
/* This separates blocks of declarations.  */
 
718
int baz;
 
719
.in -5
 
720
.ad
 
721
.fi
 
722
 
 
723
.SH "--blank-lines-after-procedures"
 
724
 
 
725
The \`-bap\' option forces a blank line after every procedure body.
 
726
 
 
727
For example, given the input
 
728
 
 
729
.in +5
 
730
.nf
 
731
.na
 
732
int
 
733
foo ()
 
734
{
 
735
  puts("Hi");
 
736
}
 
737
/* The procedure bar is even less interesting.  */
 
738
char *
 
739
bar ()
 
740
{
 
741
  puts("Hello");
 
742
}
 
743
.in -5
 
744
.ad
 
745
.fi
 
746
 
 
747
.B indent -bap\fR produces
 
748
 
 
749
.in +5
 
750
.nf
 
751
.na
 
752
int
 
753
foo ()
 
754
{
 
755
  puts ("Hi");
 
756
}
 
757
 
 
758
/* The procedure bar is even less interesting.  */
 
759
char *
 
760
bar ()
 
761
{
 
762
  puts ("Hello");
 
763
}
 
764
.in -5
 
765
.ad
 
766
.fi
 
767
 
 
768
and \fBindent -nbap\fR produces
 
769
 
 
770
.in +5
 
771
.nf
 
772
.na
 
773
int
 
774
foo ()
 
775
{
 
776
  puts ("Hi");
 
777
}
 
778
/* The procedure bar is even less interesting.  */
 
779
char *
 
780
bar ()
 
781
{
 
782
  puts ("Hello");
 
783
}
 
784
.in -5
 
785
.ad
 
786
.fi
 
787
 
 
788
No blank line will be added after the procedure \fBfoo\fR.
 
789
 
 
790
.SH "COMMENTS"
 
791
 
 
792
.B indent\fR formats both C and C++ comments. C comments are begun with
 
793
\`/*\', terminated with \`*/\' and may contain newline characters.
 
794
C++ comments begin with the delimiter \`//\' and end at the newline.
 
795
 
 
796
.B indent\fR handles comments differently depending upon their context.
 
797
.B indent\fR attempts to distinguish between comments which follow
 
798
statements, comments which follow declarations, comments following
 
799
preprocessor directives, and comments which are not preceded by code of
 
800
any sort, i.e., they begin the text of the line (although not
 
801
neccessarily in column 1).
 
802
 
 
803
.B indent\fR further distinguishes between comments found outside of
 
804
procedures and aggregates, and those found within them.  In particular,
 
805
comments beginning a line found within a procedure will be indented to
 
806
the column at which code is currently indented.  The exception to this a
 
807
comment beginning in the leftmost column;  such a comment is output
 
808
at that column.
 
809
 
 
810
.B indent\fR attempts to leave \fIboxed comments\fR unmodified.  The
 
811
general idea of such a comment is that it is enclosed in a rectangle or
 
812
\`\`box\'\' of stars or dashes to visually set it apart.  More precisely,
 
813
boxed comments are defined as those in which the initial \`/*\' is
 
814
followed immediately by the character \`*\', \`=\', \`_\', or
 
815
\`-\', or those in which the beginning comment delimiter (\`/*\')
 
816
is on a line by itself, and the following line begins with a \`*\' in
 
817
the same column as the star of the opening delimiter.
 
818
 
 
819
Examples of boxed comments are:
 
820
 
 
821
.in +5
 
822
.nf
 
823
.na
 
824
/**********************
 
825
 * Comment in a box!! *
 
826
 **********************/
 
827
 
 
828
       /*
 
829
        * A different kind of scent,
 
830
        * for a different kind of comment.
 
831
        */
 
832
.in -5
 
833
.ad
 
834
.fi
 
835
 
 
836
.B indent\fR attempts to leave boxed comments exactly as they are found
 
837
in the source file.  Thus the indentation of the comment is unchanged,
 
838
and its length is not checked in any way.  The only alteration made is
 
839
that an embedded tab character may be converted into the appropriate
 
840
number of spaces.
 
841
 
 
842
If the \`-bbb\' option is specified, all such boxed comments will be
 
843
preceded by a blank line, unless such a comment is preceded by code.
 
844
 
 
845
Comments which are not boxed comments may be formatted, which means that
 
846
the line is broken to fit within a right margin and left-filled with
 
847
whitespace.  Single newlines are equivalent to a space, but blank lines
 
848
(two or more newlines in a row) are taken to mean a paragraph break.
 
849
Formatting of comments which begin after the first column is enabled
 
850
with the \`-fca\' option.  To format those beginning in column one,
 
851
specify \`-fc1\'.  Such formatting is disabled by default.
 
852
 
 
853
The right margin for formatting defaults to 78, but may be changed with
 
854
the \`-lc\' option.  If the margin specified does not allow the
 
855
comment to be printed, the margin will be automatically extended for the
 
856
duration of that comment.  The margin is not respected if the comment is
 
857
not being formatted.
 
858
 
 
859
If the comment begins a line (i.e., there is no program text to its
 
860
left), it will be indented to the column it was found in unless the
 
861
comment is within a block of code.  In that case, such a comment will be
 
862
aligned with the indented code of that block (unless the comment began
 
863
in the first column).  This alignment may be affected by the \`-d\'
 
864
option, which specifies an amount by which such comments are moved to
 
865
the \fIleft\fR, or unindented.  For example, \`-d2\' places comments
 
866
two spaces to the left of code.  By default, comments are aligned with
 
867
code, unless they begin in the first column, in which case they are left
 
868
there by default --- to get them aligned with the code, specify \`-fc1\'.
 
869
 
 
870
Comments to the right of code will appear by default in column 33.
 
871
This may be changed with one of three options.  \`-c\' will specify
 
872
the column for comments following code, \`-cd\' specifies the
 
873
column for comments following declarations, and \`-cp\' specifies
 
874
the column for comments following preprocessor directives \fB#else\fR
 
875
and \fB#endif\fR.
 
876
 
 
877
If the code to the left of the comment exceeds the beginning column,
 
878
the comment column will be extended to the next tabstop column past
 
879
the end of the code, or in the case of preprocessor directives, to one
 
880
space past the end of the directive.  This extension lasts only for
 
881
the output of that particular comment.
 
882
 
 
883
The \`-cdb\' option places the comment delimiters on blank lines.
 
884
Thus, a single line comment like \fB/* Loving hug */\fR can be
 
885
transformed into:
 
886
 
 
887
.in +5
 
888
.nf
 
889
.na
 
890
/*
 
891
   Loving hug
 
892
 */
 
893
.in -5
 
894
.ad
 
895
.fi
 
896
 
 
897
Stars can be placed at the beginning of multi-line comments with the
 
898
\`-sc\' option.  Thus, the single-line comment above can be
 
899
transformed (with \`-cdb -sc\') into:
 
900
 
 
901
.in +5
 
902
.nf
 
903
.na
 
904
/*
 
905
 * Loving hug
 
906
 */
 
907
.in -5
 
908
.ad
 
909
.fi
 
910
 
 
911
.SH "STATEMENTS"
 
912
 
 
913
The \`-br\' or \`-bl\' option specifies how to format braces.
 
914
 
 
915
The \`-br\' option formats statement braces like this:
 
916
 
 
917
.in +5
 
918
.nf
 
919
.na
 
920
if (x > 0) {
 
921
  x--;
 
922
}
 
923
.in -5
 
924
.ad
 
925
.fi
 
926
 
 
927
The \`-bl\' option formats them like this:
 
928
 
 
929
.in +5
 
930
.nf
 
931
.na
 
932
if (x > 0)
 
933
  {
 
934
    x--;
 
935
  }
 
936
.in -5
 
937
.ad
 
938
.fi
 
939
 
 
940
If you use the \`-bl\' option, you may also want to specify the
 
941
\`-bli\' option.  This option specifies the number of spaces by
 
942
which braces are indented.  \`-bli2\', the default, gives the
 
943
result shown above.  \`-bli0\' results in the following:
 
944
 
 
945
.in +5
 
946
.nf
 
947
.na
 
948
if (x > 0)
 
949
{
 
950
  x--;
 
951
}
 
952
.in -5
 
953
.ad
 
954
.fi
 
955
 
 
956
If you are using the \`-br\' option, you probably want to also use
 
957
the \`-ce\' option.  This causes the \fBelse\fR in an if-then-else
 
958
construct to cuddle up to the immediately preceding \`}\'.  For
 
959
example, with \`-br -ce\' you get the following:
 
960
 
 
961
.in +5
 
962
.nf
 
963
.na
 
964
if (x > 0) {
 
965
  x--;
 
966
} else {
 
967
  fprintf (stderr, "...something wrong?\\n");
 
968
}
 
969
.in -5
 
970
.ad
 
971
.fi
 
972
 
 
973
With \`-br -nce\' that code would appear as
 
974
 
 
975
.in +5
 
976
.nf
 
977
.na
 
978
if (x > 0) {
 
979
  x--;
 
980
}
 
981
else {
 
982
  fprintf (stderr, "...something wrong?\\n");
 
983
}
 
984
.in -5
 
985
.ad
 
986
.fi
 
987
 
 
988
This causes the \fBwhile\fR in a do-while
 
989
loop to cuddle up to the immediately preceding \`}\'.  For
 
990
example, with \`-cdw\' you get the following:
 
991
 
 
992
.in +5
 
993
.nf
 
994
.na
 
995
do {
 
996
  x--;
 
997
} while (x);
 
998
.in -5
 
999
.ad
 
1000
.fi
 
1001
 
 
1002
With \`-ncdw\' that code would appear as
 
1003
 
 
1004
.in +5
 
1005
.nf
 
1006
.na
 
1007
do {
 
1008
  x--;
 
1009
}
 
1010
while (x);
 
1011
.in -5
 
1012
.ad
 
1013
.fi
 
1014
 
 
1015
The \`-cli\' option specifies the number of spaces that case labels
 
1016
should be indented to the right of the containing \fBswitch\fR
 
1017
statement.
 
1018
 
 
1019
The default gives code like:
 
1020
 
 
1021
.in +5
 
1022
.nf
 
1023
.na
 
1024
switch (i)
 
1025
  {
 
1026
  case 0:
 
1027
    break;
 
1028
  case 1:
 
1029
    {
 
1030
      ++i;
 
1031
    }
 
1032
  default:
 
1033
    break;
 
1034
  }
 
1035
.in -5
 
1036
.ad
 
1037
.fi
 
1038
 
 
1039
Using the \`-cli2\' that would become:
 
1040
 
 
1041
.in +5
 
1042
.nf
 
1043
.na
 
1044
switch (i)
 
1045
  {
 
1046
    case 0:
 
1047
      break;
 
1048
    case 1:
 
1049
      {
 
1050
        ++i;
 
1051
      }
 
1052
    default:
 
1053
      break;
 
1054
  }
 
1055
.in -5
 
1056
.ad
 
1057
.fi
 
1058
 
 
1059
The indentation of the braces below a case statement can be
 
1060
controlled with the \`-cbi\fIn\fR\' option.  For example,
 
1061
using \`-cli2 -cbi0\' results in:
 
1062
 
 
1063
.in +5
 
1064
.nf
 
1065
.na
 
1066
switch (i)
 
1067
  {
 
1068
    case 0:
 
1069
      break;
 
1070
    case 1:
 
1071
    {
 
1072
      ++i;
 
1073
    }
 
1074
    default:
 
1075
      break;
 
1076
  }
 
1077
.in -5
 
1078
.ad
 
1079
.fi
 
1080
 
 
1081
If a semicolon is on the same line as a \fBfor\fR or \fBwhile\fR
 
1082
statement, the \`-ss\' option will cause a space to be placed before
 
1083
the semicolon.  This emphasizes the semicolon, making it clear that the
 
1084
body of the \fBfor\fR or \fBwhile\fR statement is an empty statement.
 
1085
\`-nss\' disables this feature.
 
1086
 
 
1087
The \`-pcs\' option causes a space to be placed between the name of
 
1088
the procedure being called and the \`(\' (for example, \fBputs\ ("Hi");\fR.  The \`-npcs\' option would give \fBputs("Hi");\fR).
 
1089
 
 
1090
 
 
1091
If the \`-cs\' option is specified, \fBindent\fR puts a space after
 
1092
a cast operator.
 
1093
 
 
1094
The \`-bs\' option ensures that there is a space between the
 
1095
keyword \fBsizeof\fR and its argument.  In some versions, this is
 
1096
known as the \`Bill_Shannon\' option.
 
1097
 
 
1098
The \`-saf\' option forces a space between an \fBfor\fR
 
1099
and the following parenthesis.  This is the default.
 
1100
 
 
1101
The \`-sai\' option forces a space between an \fBif\fR
 
1102
and the following parenthesis.  This is the default.
 
1103
 
 
1104
The \`-saw\' option forces a space between an \fBwhile\fR
 
1105
and the following parenthesis.  This is the default.
 
1106
 
 
1107
The \`-prs\' option causes all parentheses to be seperated with
 
1108
a space from the what is between them.  For example, using \`-prs\'
 
1109
results in code like:
 
1110
 
 
1111
.in +5
 
1112
.nf
 
1113
.na
 
1114
  while ( ( e_code - s_code ) < ( dec_ind - 1 ) )
 
1115
    {
 
1116
      set_buf_break ( bb_dec_ind );
 
1117
      *e_code++ = \' \';
 
1118
    }
 
1119
.in -5
 
1120
.ad
 
1121
.fi
 
1122
 
 
1123
.SH "DECLARATIONS"
 
1124
 
 
1125
By default \fBindent\fR will line up identifiers, in the column
 
1126
specified by the \`-di\' option.  For example, \`-di16\' makes
 
1127
things look like:
 
1128
 
 
1129
.in +5
 
1130
.nf
 
1131
.na
 
1132
int             foo;
 
1133
char           *bar;
 
1134
.in -5
 
1135
.ad
 
1136
.fi
 
1137
 
 
1138
Using a small value (such as one or two) for the \`-di\' option can
 
1139
be used to cause the identifiers to be placed in the first available
 
1140
position; for example:
 
1141
 
 
1142
.in +5
 
1143
.nf
 
1144
.na
 
1145
int foo;
 
1146
char *bar;
 
1147
.in -5
 
1148
.ad
 
1149
.fi
 
1150
 
 
1151
The value given to the \`-di\' option will still affect variables
 
1152
which are put on separate lines from their types, for example
 
1153
\`-di2\' will lead to:
 
1154
 
 
1155
.in +5
 
1156
.nf
 
1157
.na
 
1158
int
 
1159
  foo;
 
1160
.in -5
 
1161
.ad
 
1162
.fi
 
1163
 
 
1164
If the \`-bc\' option is specified, a newline is forced after each
 
1165
comma in a declaration.  For example,
 
1166
 
 
1167
.in +5
 
1168
.nf
 
1169
.na
 
1170
int a,
 
1171
  b,
 
1172
  c;
 
1173
.in -5
 
1174
.ad
 
1175
.fi
 
1176
 
 
1177
With the \`-nbc\' option this would look like
 
1178
 
 
1179
.in +5
 
1180
.nf
 
1181
.na
 
1182
int a, b, c;
 
1183
.in -5
 
1184
.ad
 
1185
.fi
 
1186
 
 
1187
The \`-bfda\' option causes a newline to be forced after the comma
 
1188
separating the arguments of a function declaration.  The arguments will
 
1189
appear at the current indention level matching the opening paren.  This 
 
1190
is particularly helpful for functions with long argument lists.   For 
 
1191
example,
 
1192
 
 
1193
.in +5
 
1194
.nf
 
1195
.na
 
1196
void foo (int arg1, char arg2, int *arg3, long arg4, char arg5);
 
1197
.in -5
 
1198
.ad
 
1199
.fi
 
1200
With the \`-bfda\' option this would look like
 
1201
 
 
1202
.in +5
 
1203
.nf
 
1204
.na
 
1205
void foo (int arg1,
 
1206
          char arg2,
 
1207
          int *arg3,
 
1208
          long arg4,
 
1209
          char arg5);
 
1210
.in -5
 
1211
.ad
 
1212
.fi
 
1213
 
 
1214
The \`-psl\' option causes the type of a procedure being defined to
 
1215
be placed on the line before the name of the procedure.  This style is
 
1216
required for the \fBetags\fR program to work correctly, as well as some
 
1217
of the \fBc-mode\fR functions of Emacs.
 
1218
 
 
1219
You must use the \`-T\'
 
1220
option to tell \fBindent\fR the name of all the typenames in your
 
1221
program that are defined by \fBtypedef\fR.  \`-T\' can be specified
 
1222
more than once, and all names specified are used.  For example, if your
 
1223
program contains
 
1224
 
 
1225
.in +5
 
1226
.nf
 
1227
.na
 
1228
typedef unsigned long CODE_ADDR;
 
1229
typedef enum {red, blue, green} COLOR;
 
1230
.in -5
 
1231
.ad
 
1232
.fi
 
1233
 
 
1234
you would use the options \`-T CODE_ADDR -T COLOR\'.
 
1235
 
 
1236
The \`-brs\' or \`-bls\' option specifies how to format braces
 
1237
in struct declarations.  The \`-brs\' option formats braces like
 
1238
this:
 
1239
 
 
1240
.in +5
 
1241
.nf
 
1242
.na
 
1243
struct foo {
 
1244
  int x;
 
1245
};
 
1246
.in -5
 
1247
.ad
 
1248
.fi
 
1249
 
 
1250
The \`-bls\' option formats them like this:
 
1251
 
 
1252
.in +5
 
1253
.nf
 
1254
.na
 
1255
struct foo
 
1256
{
 
1257
  int x;
 
1258
};
 
1259
.in -5
 
1260
.ad
 
1261
.fi
 
1262
 
 
1263
.SH "INDENTATION"
 
1264
 
 
1265
One issue in the formatting of code is how far each line should be
 
1266
indented from the left margin.  When the beginning of a statement such
 
1267
as \fBif\fR or \fBfor\fR is encountered, the indentation level is
 
1268
increased by the value specified by the \`-i\' option.  For example,
 
1269
use \`-i8\' to specify an eight character indentation for each
 
1270
level.  When a statement is broken across two lines, the second line is
 
1271
indented by a number of additional spaces specified by the \`-ci\'
 
1272
option.  \`-ci\' defaults to 0.  However, if the \`-lp\' option is
 
1273
specified, and a line has a left parenthesis which is not closed on that
 
1274
line, then continuation lines will be lined up to start at the character
 
1275
position just after the left parenthesis.  This processing also applies
 
1276
to \`[\' and applies to \`{\' when it occurs in initialization
 
1277
lists.  For example, a piece of continued code might look like this with
 
1278
\`-nlp -ci3\' in effect:
 
1279
 
 
1280
.in +5
 
1281
.nf
 
1282
.na
 
1283
  p1 = first_procedure (second_procedure (p2, p3),
 
1284
     third_procedure (p4, p5));
 
1285
.in -5
 
1286
.ad
 
1287
.fi
 
1288
 
 
1289
With \`-lp\' in effect the code looks somewhat clearer:
 
1290
 
 
1291
.in +5
 
1292
.nf
 
1293
.na
 
1294
  p1 = first_procedure (second_procedure (p2, p3),
 
1295
                        third_procedure (p4, p5));
 
1296
.in -5
 
1297
.ad
 
1298
.fi
 
1299
 
 
1300
When a statement is broken in between two or more paren pairs (...),
 
1301
each extra pair causes the indentation level extra indentation:
 
1302
 
 
1303
.in +5
 
1304
.nf
 
1305
.na
 
1306
if ((((i < 2 &&
 
1307
        k > 0) || p == 0) &&
 
1308
    q == 1) ||
 
1309
  n = 0)
 
1310
.in -5
 
1311
.ad
 
1312
.fi
 
1313
 
 
1314
The option \`-ip\fIN\fR\' can be used to set the extra offset per paren.
 
1315
For instance, \`-ip0\' would format the above as:
 
1316
 
 
1317
.in +5
 
1318
.nf
 
1319
.na
 
1320
if ((((i < 2 &&
 
1321
  k > 0) || p == 0) &&
 
1322
  q == 1) ||
 
1323
  n = 0)
 
1324
.in -5
 
1325
.ad
 
1326
.fi
 
1327
 
 
1328
.B indent\fR assumes that tabs are placed at regular intervals of both
 
1329
input and output character streams.  These intervals are by default 8
 
1330
columns wide, but (as of version 1.2) may be changed by the \`-ts\'
 
1331
option.  Tabs are treated as the equivalent number of spaces.
 
1332
 
 
1333
The indentation of type declarations in old-style function definitions
 
1334
is controlled by the \`-ip\' parameter.  This is a numeric parameter
 
1335
specifying how many spaces to indent type declarations.  For example,
 
1336
the default \`-ip5\' makes definitions look like this:
 
1337
 
 
1338
.in +5
 
1339
.nf
 
1340
.na
 
1341
char *
 
1342
create_world (x, y, scale)
 
1343
     int x;
 
1344
     int y;
 
1345
     float scale;
 
1346
{
 
1347
  . . .
 
1348
}
 
1349
.in -5
 
1350
.ad
 
1351
.fi
 
1352
 
 
1353
For compatibility with other versions of indent, the option \`-nip\'
 
1354
is provided, which is equivalent to \`-ip0\'.
 
1355
 
 
1356
ANSI C allows white space to be placed on preprocessor command lines
 
1357
between the character \`#\' and the command name.  By default,
 
1358
.B indent\fR removes this space, but specifying the \`-lps\' option
 
1359
directs \fBindent\fR to leave this space unmodified.
 
1360
 
 
1361
.SH "BREAKING LONG LINES"
 
1362
 
 
1363
With the option \`-l\fIn\fR\', or \`--line-length\fIn\fR\', it is
 
1364
possible to specify the maximum length of a line of C code, not including
 
1365
possible comments that follow it.
 
1366
 
 
1367
When lines become longer then the specified line length, GNU \fBindent\fR
 
1368
tries to break the line at a logical place.  This is new as of version 2.1
 
1369
however and not very intelligent or flexible yet.
 
1370
 
 
1371
Currently there are two options that allows one to interfere with the
 
1372
algorithm that determines where to break a line.
 
1373
 
 
1374
The \`-bbo\' option causes GNU \fBindent\fR to prefer to break
 
1375
long lines before the boolean operators \fB&&\fR and \fB||\fR.  The
 
1376
\`-nbbo\' option causes GNU \fBindent\fR not have that
 
1377
preference.  For example, the default option \`-bbo\' (together
 
1378
with \`--line-length60\' and \`--ignore-newlines\') makes code
 
1379
look like this:
 
1380
 
 
1381
.in +5
 
1382
.nf
 
1383
.na
 
1384
  if (mask
 
1385
      && ((mask[0] == \'\\0\')
 
1386
          || (mask[1] == \'\\0\'
 
1387
              && ((mask[0] == \'0\') || (mask[0] == \'*\')))))
 
1388
.in -5
 
1389
.ad
 
1390
.fi
 
1391
 
 
1392
Using the option \`-nbbo\' will make it look like this:
 
1393
 
 
1394
.in +5
 
1395
.nf
 
1396
.na
 
1397
  if (mask &&
 
1398
      ((mask[0] == \'\\0\') ||
 
1399
       (mask[1] == \'\\0\' &&
 
1400
        ((mask[0] == \'0\') || (mask[0] == \'*\')))))
 
1401
.in -5
 
1402
.ad
 
1403
.fi
 
1404
 
 
1405
The default \`-hnl\', however, honours newlines in the input file by
 
1406
giving them the highest possible priority to break lines at.  For example,
 
1407
when the input file looks like this:
 
1408
 
 
1409
.in +5
 
1410
.nf
 
1411
.na
 
1412
  if (mask
 
1413
      && ((mask[0] == \'\\0\')
 
1414
      || (mask[1] == \'\\0\' && ((mask[0] == \'0\') || (mask[0] == \'*\')))))
 
1415
.in -5
 
1416
.ad
 
1417
.fi
 
1418
 
 
1419
then using the option \`-hnl\', or \`--honour-newlines\',
 
1420
together with the previously mentioned \`-nbbo\' and
 
1421
\`--line-length60\', will cause the output not to be what is given
 
1422
in the last example but instead will prefer to break at the positions
 
1423
where the code was broken in the input file:
 
1424
 
 
1425
.in +5
 
1426
.nf
 
1427
.na
 
1428
  if (mask
 
1429
      && ((mask[0] == \'\\0\')
 
1430
          || (mask[1] == \'\\0\' &&
 
1431
              ((mask[0] == \'0\') || (mask[0] == \'*\')))))
 
1432
.in -5
 
1433
.ad
 
1434
.fi
 
1435
 
 
1436
The idea behind this option is that lines which are too long, but are already
 
1437
broken up, will not be touched by GNU \fBindent\fR.  Really messy code
 
1438
should be run through \fBindent\fR at least once using the
 
1439
\`--ignore-newlines\' option though.
 
1440
 
 
1441
.SH "DISABLING FORMATTING"
 
1442
 
 
1443
Formatting of C code may be disabled for portions of a program by
 
1444
embedding special \fIcontrol comments\fR in the program.  To turn off
 
1445
formatting for a section of a program, place the disabling control
 
1446
comment \fB/* *INDENT-OFF* */\fR on a line by itself just before that
 
1447
section.  Program text scanned after this control comment is output
 
1448
precisely as input with no modifications until the corresponding
 
1449
enabling comment is scanned on a line by itself.  The disabling control
 
1450
comment is \fB/* *INDENT-ON* */\fR, and any text following the comment
 
1451
on the line is also output unformatted.  Formatting begins again with
 
1452
the input line following the enabling control comment.
 
1453
 
 
1454
More precisely, \fBindent\fR does not attempt to verify the closing
 
1455
delimiter (\fB*/\fR) for these C comments, and any whitespace on the
 
1456
line is totally transparent.
 
1457
 
 
1458
These control comments also function in their C++ formats, namely
 
1459
.B // *INDENT-OFF*\fR and \fB// *INDENT-ON*\fR.
 
1460
 
 
1461
It should be noted that the internal state of \fBindent\fR remains
 
1462
unchanged over the course of the unformatted section.  Thus, for
 
1463
example, turning off formatting in the middle of a function and
 
1464
continuing it after the end of the function may lead to bizarre
 
1465
results.  It is therefore wise to be somewhat modular in selecting code
 
1466
to be left unformatted.
 
1467
 
 
1468
As a historical note, some earlier versions of \fBindent\fR produced
 
1469
error messages beginning with \fB*INDENT**\fR.  These versions of
 
1470
.B indent\fR were written to ignore any input text lines which began
 
1471
with such error messages.  I have removed this incestuous feature from
 
1472
GNU \fBindent\fR.
 
1473
 
 
1474
.SH "MISCELLANEOUS OPTIONS"
 
1475
 
 
1476
To find out what version of \fBindent\fR you have, use the command
 
1477
.B indent -version\fR.  This will report the version number of
 
1478
.B indent\fR, without doing any of the normal processing.
 
1479
 
 
1480
The \`-v\' option can be used to turn on verbose mode.  When in
 
1481
verbose mode, \fBindent\fR reports when it splits one line of input
 
1482
into two more more lines of output, and gives some size statistics at
 
1483
completion. 
 
1484
 
 
1485
The \`-pmt\' option causes \fBindent\fR to preserve the access
 
1486
and modification times on the output files.  Using this option
 
1487
has the advantage that running indent on all source and header
 
1488
files in a project won\'t cause \fBmake\fR to rebuild all targets.
 
1489
This option is only available on Operating Systems that have the
 
1490
POSIX \fButime(2)\fR function.
 
1491
 
 
1492
.SH "BUGS"
 
1493
 
 
1494
Please report any bugs to bug-indent@@gnu.org.
 
1495
 
 
1496
When \fBindent\fR is run twice on a file, with the same profile,
 
1497
it should \fInever\fR change that file the second time.  With the
 
1498
current design of \fBindent\fR, this can not be guaranteed, however,
 
1499
and it has not been extensively tested.
 
1500
 
 
1501
.B indent\fR does not understand C.  In some cases this leads to
 
1502
the inability to join lines.  The result is that running a file
 
1503
through \fBindent\fR is \fIirreversible\fR, even if the used input
 
1504
file was the result of running \fBindent\fR with a given profile
 
1505
(\`.indent.pro\').
 
1506
 
 
1507
While an attempt was made to get \fBindent\fR working for C++, is
 
1508
will not do a good job on any C++ source except the very simple.
 
1509
 
 
1510
.B indent\fR does not look at the given \`--line-length\' option
 
1511
when writing comments to the output file.  This results often in comments
 
1512
being put far to the right.  In order to prohibit \fBindent\fR from
 
1513
joining a broken line that has a comment at the end, make sure that the
 
1514
comments start on the first line of the break.
 
1515
 
 
1516
.B indent\fR does not count lines and comments (see the \`-v\'
 
1517
option) when \fBindent\fR is turned off with 
 
1518
.B /* *INDENT-OFF* */\fR.
 
1519
 
 
1520
Comments of the form \fB/*UPPERCASE*/\fR are not treated as comment but as an
 
1521
identifier, causing them to be joined with the next line. This renders
 
1522
comments of this type useless, unless they are embedded in the code to
 
1523
begin with.
 
1524
 
 
1525
.SH "COPYRIGHT"
 
1526
 
 
1527
The following copyright notice applies to the \fBindent\fR program.
 
1528
The copyright and copying permissions for this manual appear near the
 
1529
beginning of \`indent.texinfo\' and \`indent.info\', and near the
 
1530
end of \`indent.1\'.
 
1531
 
 
1532
.nf
 
1533
.na
 
1534
Copyright (c) 2001 David Ingamells.
 
1535
Copyright (c) 1999 Carlo Wood.
 
1536
Copyright (c) 1995, 1996 Joseph Arceneaux.
 
1537
Copyright (c) 1989, 1992, 1993, 1994, 1995, 1996 Free Software Foundation
 
1538
Copyright (c) 1985 Sun Microsystems, Inc.
 
1539
Copyright (c) 1980 The Regents of the University of California.
 
1540
Copyright (c) 1976 Board of Trustees of the University of Illinois.
 
1541
All rights reserved.
 
1542
 
 
1543
Redistribution and use in source and binary forms are permitted
 
1544
provided that the above copyright notice and this paragraph are
 
1545
duplicated in all such forms and that any documentation,
 
1546
advertising materials, and other materials related to such
 
1547
distribution and use acknowledge that the software was developed
 
1548
by the University of California, Berkeley, the University of Illinois,
 
1549
Urbana, and Sun Microsystems, Inc.  The name of either University
 
1550
or Sun Microsystems may not be used to endorse or promote products
 
1551
derived from this software without specific prior written permission.
 
1552
THIS SOFTWARE IS PROVIDED \`\`AS IS\'\' AND WITHOUT ANY EXPRESS OR
 
1553
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 
1554
WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
 
1555
PURPOSE.
 
1556
.ad
 
1557
.fi
 
1558
 
 
1559
.SH "Options\' Cross Key"
 
1560
 
 
1561
Here is a list of options alphabetized by long option, to help you find
 
1562
the corresponding short option.
 
1563
 
 
1564
 
 
1565
.in +5
 
1566
.nf
 
1567
.na
 
1568
--blank-lines-after-commas                      -bc             
 
1569
--blank-lines-after-declarations                -bad            
 
1570
--blank-lines-after-procedures                  -bap            
 
1571
--blank-lines-before-block-comments             -bbb            
 
1572
--braces-after-if-line                          -bl             
 
1573
--brace-indent                                  -bli
 
1574
--braces-after-struct-decl-line                 -bls
 
1575
--braces-on-if-line                             -br             
 
1576
--braces-on-struct-decl-line                    -brs
 
1577
--break-after-boolean-operator                  -nbbo
 
1578
--break-before-boolean-operator                 -bbo
 
1579
--break-function-decl-args                      -bfda
 
1580
--case-indentation                              -cli\fIn\fR     
 
1581
--case-brace-indentation                        -cbi\fIn\fR
 
1582
--comment-delimiters-on-blank-lines             -cdb            
 
1583
--comment-indentation                           -c\fIn\fR       
 
1584
--continuation-indentation                      -ci\fIn\fR      
 
1585
--continue-at-parentheses                       -lp             
 
1586
--cuddle-do-while                               -cdw
 
1587
--cuddle-else                                   -ce             
 
1588
--declaration-comment-column                    -cd\fIn\fR      
 
1589
--declaration-indentation                       -di\fIn\fR      
 
1590
--dont-break-function-decl-args                 -nbfda
 
1591
--dont-break-procedure-type                     -npsl           
 
1592
--dont-cuddle-do-while                          -ncdw
 
1593
--dont-cuddle-else                              -nce            
 
1594
--dont-format-comments                          -nfca           
 
1595
--dont-format-first-column-comments             -nfc1           
 
1596
--dont-line-up-parentheses                      -nlp            
 
1597
--dont-space-special-semicolon                  -nss
 
1598
--dont-star-comments                            -nsc            
 
1599
--else-endif-column                             -cp\fIn\fR
 
1600
--format-all-comments                           -fca            
 
1601
--format-first-column-comments                  -fc1            
 
1602
--gnu-style                                     -gnu            
 
1603
--honour-newlines                               -hnl
 
1604
--ignore-newlines                               -nhnl
 
1605
--ignore-profile                                -npro           
 
1606
--indent-level                                  -i\fIn\fR       
 
1607
--k-and-r-style                                 -kr             
 
1608
--leave-optional-blank-lines                    -nsob           
 
1609
--leave-preprocessor-space                      -lps
 
1610
--line-comments-indentation                     -d\fIn\fR       
 
1611
--line-length                                   -l\fIn\fR       
 
1612
--no-blank-lines-after-commas                   -nbc            
 
1613
--no-blank-lines-after-declarations             -nbad           
 
1614
--no-blank-lines-after-procedures               -nbap           
 
1615
--no-blank-lines-before-block-comments          -nbbb           
 
1616
--no-comment-delimiters-on-blank-lines          -ncdb           
 
1617
--no-space-after-casts                          -ncs            
 
1618
--no-parameter-indentation                      -nip            
 
1619
--no-space-after-for                            -nsaf
 
1620
--no-space-after-function-call-names            -npcs           
 
1621
--no-space-after-if                             -nsai
 
1622
--no-space-after-parentheses                    -nprs
 
1623
--no-space-after-while                          -nsaw
 
1624
--no-tabs                                       -nut
 
1625
--no-verbosity                                  -nv             
 
1626
--original                                      -orig
 
1627
--parameter-indentation                         -ip\fIn\fR      
 
1628
--paren-indentation                             -pi\fIn\fR
 
1629
--preserve-mtime                                -pmt
 
1630
--procnames-start-lines                         -psl            
 
1631
--space-after-cast                              -cs             
 
1632
--space-after-for                               -saf
 
1633
--space-after-if                                -sai
 
1634
--space-after-parentheses                       -prs
 
1635
--space-after-procedure-calls                   -pcs            
 
1636
--space-after-while                             -saw
 
1637
--space-special-semicolon                       -ss             
 
1638
--standard-output                               -st             
 
1639
--start-left-side-of-comments                   -sc             
 
1640
--struct-brace-indentation                      -sbi\fIn\fR
 
1641
--swallow-optional-blank-lines                  -sob            
 
1642
--tab-size                                      -ts\fIn\fR      
 
1643
--use-tabs                                      -ut
 
1644
--verbose                                       -v              
 
1645
.in -5
 
1646
.ad
 
1647
.fi
 
1648
 
 
1649
.SH "RETURN VALUE"
 
1650
Unknown
 
1651
.SH FILES
 
1652
.br
 
1653
.nf
 
1654
.\" set tabstop to longest possible filename, plus a wee bit
 
1655
.ta \w'$HOME/.indent.pro   'u
 
1656
\fI$HOME/.indent.pro\fR holds default options for indent.
 
1657
.SH "AUTHORS"
 
1658
.br
 
1659
Carlo Wood
 
1660
.br
 
1661
Joseph Arceneaux
 
1662
.br
 
1663
Jim Kingdon
 
1664
.br
 
1665
David Ingamells
 
1666
.SH "HISTORY"
 
1667
Derived from the UCB program "indent".
 
1668
.SH "COPYING"
 
1669
Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
 
1670
Copyright (C) 1995, 1996 Joseph Arceneaux.
 
1671
Copyright (C) 1999 Carlo Wood.
 
1672
Copyright (C) 2001 David Ingamells.
 
1673
 
 
1674
Permission is granted to make and distribute verbatim copies of
 
1675
this manual provided the copyright notice and this permission notice
 
1676
are preserved on all copies.
 
1677
 
 
1678