Manual Pages for UNIX Darwin command on man indent
MyWebUniversity

Manual Pages for UNIX Darwin command on man indent

INDENT(1) BSD General Commands Manual INDENT(1)

NAME

iinnddeenntt - indent and format C program source

SYNOPSIS

iinnddeenntt [inputfile [outputfile]] [-bbaacccc | -nnbbaacccc] [-bbaadd | -nnbbaadd]

[-bbaapp | -nnbbaapp] [-bbbbbb | -nnbbbbbb] [-bbcc | -nnbbcc] [-bbll] [-bbrr] [-ccn]

[-ccddn] [-ccddbb | -nnccddbb] [-ccee | -nnccee] [-cciin] [-cclliin] [-ddn] [-ddiin]

[-ffcc11 | -nnffcc11] [-iin] [-iipp | -nniipp] [-lln] [-llccn] [-llpp | -nnllpp]

[-nnpprroo] [-ppccss | -nnppccss] [-ppssll | -nnppssll] [-sscc | -nnsscc] [-ssoobb | -nnssoobb]

[-sstt] [-ttrrooffff] [-vv | -nnvv]

DESCRIPTION

The iinnddeenntt utility is a C program formatter. It reformats the C program in the inputfile according to the switches. The switches which can be specified are described below. They may appear before or after the file names.

NNOOTTEE: If you only specify an inputfile, the formatting is done `in-

place', that is, the formatted file is written back into inputfile and a backup copy of inputfile is written in the current directory. If inputfile is named `/blah/blah/file', the backup file is named file.BAK. If outputfile is specified, iinnddeenntt checks to make sure it is different from inputfile. The options listed below control the formatting style imposed by iinnddeenntt.

-bbaacccc, -nnbbaacccc If -bbaacccc is specified, a blank line is forced around

every conditional compilation block. For example, in

front of every #ifdef and after every #endif. Other

blank lines surrounding such blocks will be swallowed.

Default: -nnbbaacccc.

-bbaadd, -nnbbaadd If -bbaadd is specified, a blank line is forced after every

block of declarations. Default: -nnbbaadd.

-bbaapp, -nnbbaapp If -bbaapp is specified, a blank line is forced after every

procedure body. Default: -nnbbaapp.

-bbbbbb, -nnbbbbbb If -bbbbbb is specified, a blank line is forced before every

block comment. Default: -nnbbbbbb.

-bbcc, -nnbbcc If -bbcc is specified, then a newline is forced after each

comma in a declaration. -nnbbcc turns off this option.

Default: -bbcc.

-bbrr, -bbll Specifying -bbll lines up compound statements like this:

if (...) { code }

Specifying -bbrr (the default) makes them look like this:

if (...) { code }

-bbss, -nnbbss If -bbss is specified, a blank is forced after ssiizzeeooff.

Default: -nnbbss.

-ccn The column in which comments on code start. Default:

-cc3333.

-ccddn The column in which comments on declarations start. The

default is for these comments to start in the same column as those on code.

-ccddbb, -nnccddbb Enables (disables) the placement of comment delimiters on

blank lines. With this option enabled, comments look like this: /* * this is a comment */ Rather than like this: /* this is a comment */ This only affects block comments, not comments to the

right of code. Default: -ccddbb.

-ccee, -nnccee Enables (disables) forcing `else's to cuddle up to the

immediately preceding `}'. Default: -ccee.

-cciin Sets the continuation indent to be n. Continuation lines

will be indented that far from the beginning of the first

line of the statement. Parenthesized expressions have

extra indentation added to indicate the nesting, unless

-llpp is in effect. -ccii defaults to the same value as -ii.

-cclliin Causes case labels to be indented n tab stops to the

right of the containing sswwiittcchh statement. -ccllii00..55 causes

case labels to be indented half a tab stop. Default:

-ccllii00.

-ddn Controls the placement of comments which are not to the

right of code. For example, -dd11 means that such comments

are placed one indentation level to the left of code.

Specifying the default -dd00 lines up these comments with

the code. See the section on comment indentation below.

-ddiin Specifies the indentation, in character positions, from a

declaration keyword to the following identifier.

Default: -ddii1166.

-ddjj, -nnddjj -ddjj left justifies declarations. -nnddjj indents declara-

tions the same as code. Default: -nnddjj.

-eeii, -nneeii Enables (disables) special eellssee-iiff processing. If it's

enabled, an iiff following an eellssee will have the same

indentation as the preceding iiff statement. Default: -eeii.

-eeeeii, -nneeeeii Enables (disables) extra indentation on continuation

lines of the expression part of iiff and wwhhiillee statements.

These continuation lines will be indented one extra

level. Default: -nneeeeii.

-ffcc11, -nnffcc11 Enables (disables) the formatting of comments that start

in column 1. Often, comments whose leading `/' is in

column 1 have been carefully hand formatted by the pro-

grammer. In such cases, -nnffcc11 should be used. Default:

-ffcc11.

-iin The number of spaces for one indentation level. Default:

-ii88.

-iipp, -nniipp Enables (disables) the indentation of parameter declara-

tions from the left margin. Default: -iipp.

-lln Maximum length of an output line. Default: -ll7788.

-llpp, -nnllpp Lines up code surrounded by parenthesis in continuation

lines. If a line has a left paren which is not closed on that line, then continuation lines will be lined up to start at the character position just after the left paren. For example, here is how a piece of continued

code looks with -nnllpp in effect:

p1 = firstprocedure(secondprocedure(p2, p3), thirdprocedure(p4,p5));

With -llpp in effect (the default) the code looks somewhat

clearer: p1 = firstprocedure(secondprocedure(p2, p3), thirdprocedure(p4,p5)); Inserting two more newlines we get: p1 = firstprocedure(secondprocedure(p2, p3), thirdprocedure(p4 p5));

-nnpprroo Causes the profile files, `./.indent.pro' and

`~/.indent.pro', to be ignored.

-ppccss, -nnppccss If true (-ppccss) all procedure calls will have a space

inserted between the name and the `('. Default: -nnppccss.

-ppssll, -nnppssll If true (-ppssll) the names of procedures being defined are

placed in column 1 - their types, if any, will be left on

the previous lines. Default: -ppssll.

-sscc, -nnsscc Enables (disables) the placement of asterisks (`*'s) at

the left edge of all comments. Default: -sscc.

-ssoobb, -nnssoobb If -ssoobb is specified, indent will swallow optional blank

lines. You can use this to get rid of blank lines after

declarations. Default: -nnssoobb.

-sstt Causes iinnddeenntt to take its input from stdin, and put its

output to stdout.

-TTtypename Adds typename to the list of type keywords. Names accu-

mulate: -TT can be specified more than once. You need to

specify all the typenames that appear in your program

that are defined by ttyyppeeddeeff - nothing will be harmed if

you miss a few, but the program won't be formatted as nicely as it should. This sounds like a painful thing to have to do, but it's really a symptom of a problem in C: ttyyppeeddeeff causes a syntactic change in the language and iinnddeenntt can't find all instances of ttyyppeeddeeff.

-ttrrooffff Causes iinnddeenntt to format the program for processing by

troff(1). It will produce a fancy listing in much the same spirit as vgrind(1). If the output file is not specified, the default is standard output, rather than formatting in place.

-vv, -nnvv -vv turns on `verbose' mode; -nnvv turns it off. When in

verbose mode, iinnddeenntt reports when it splits one line of input into two or more lines of output, and gives some

size statistics at completion. Default: -nnvv.

You may set up your own `profile' of defaults to iinnddeenntt by creating a

file called .indent.pro in your login directory and/or the current direc-

tory and including whatever switches you like. A `.indent.pro' in the

current directory takes precedence over the one in your login directory. If iinnddeenntt is run and a profile file exists, then it is read to set up the

program's defaults. Switches on the command line, though, always over-

ride profile switches. The switches should be separated by spaces, tabs or newlines. CCoommmmeennttss `Box' comments. iinnddeenntt assumes that any comment with a dash or star

immediately after the start of comment (that is, `/*-' or `/**') is a

comment surrounded by a box of stars. Each line of such a comment is

left unchanged, except that its indentation may be adjusted to account

for the change in indentation of the first line of the comment.

Straight text. All other comments are treated as straight text. iinnddeenntt fits as many words (separated by blanks, tabs, or newlines) on a line as possible. Blank lines break paragraphs. CCoommmmeenntt iinnddeennttaattiioonn

If a comment is on a line with code it is started in the `comment col-

umn', which is set by the -ccn command line parameter. Otherwise, the

comment is started at n indentation levels less than where code is cur-

rently being placed, where n is specified by the -ddn command line parame-

ter. If the code on a line extends past the comment column, the comment starts further to the right, and the right margin may be automatically extended in extreme cases. PPrreepprroocceessssoorr lliinneess

In general, iinnddeenntt leaves preprocessor lines alone. The only reformat-

ting that it will do is to straighten up trailing comments. It leaves

embedded comments alone. Conditional compilation (##iiffddeeff......##eennddiiff) is

recognized and iinnddeenntt attempts to correctly compensate for the syntactic peculiarities introduced. CC ssyynnttaaxx iinnddeenntt understands a substantial amount about the syntax of C, but it has

a `forgiving' parser. It attempts to cope with the usual sorts of incom-

plete and misformed syntax. In particular, the use of macros like:

#define forever for(;;)

is handled properly. ENVIRONMENT iinnddeenntt uses the HOME environment variable. FILES

./.indent.pro profile file

~/.indent.pro profile file

HISTORY The iinnddeenntt command appeared in 4.2BSD.

BUGS

iinnddeenntt has even more switches than ls(1). A common mistake that often causes grief is typing:

indent *.c

to the shell in an attempt to indent all the C programs in a directory.

This is probably a bug, not a feature. BSD June 29, 2004 BSD




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™