Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ indent(1) — A/UX 2.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cb(1)




indent(1) indent(1)
NAME indent - indent and format C program source SYNOPSIS indent input [output] [flags] DESCRIPTION indent is intended primarily as a C program formatter. Specifically, indent will: indent code lines align comments insert spaces around operators where necessary break up declaration lists as in int a,b,c;. indent will not break up long statements to make them fit within the maximum line length, but it will flag lines that are too long. Lines will be broken so that each statement starts a new line. Comments will be lined up one indentation level to the left of the code, and an attempt is made to line up identifiers in declarations. The flags which can be specified follow. They may appear before or after the file names. If the output file is omit- ted, the formatted file will be written back into input and a ``backup'' copy of input will be written in the current directory. If input is named /blah/blah/file, the backup file will be named .Bfile. If output is specified, indent checks to make sure it is different from input. The following flag options may be used to control the for- matting style imposed by indent. -lnnn Maximum length of an output line. The default is 75. -cnnn The column in which comments will start. The de- fault is 33. -cdnnn The column in which comments on declarations will start. The default is for these comments to start in the same column as other comments. -innn The number of spaces for one indentation level. The default is 4. -dj,-ndj -dj will cause declarations to be left justified. -ndj will cause them to be indented the same as code. The default is -ndj. -v,-nv -v turns on ``verbose'' mode, -nv turns it off. When in verbose mode, indent will report when it April, 1990 1



indent(1) indent(1)
splits one line of input into two or more lines of output, and it will give some size statistics at completion. The default is -nv. -bc,-nbc If -bc is specified, then a newline will be forced after each comma in a declaration. -nbc will turn off this flag option. The default is -bc. -dnnn This flag option controls the placement of com- ments which are not to the right of code. Speci- fying -d2 means that such comments will be placed two indentation levels to the left of code. The default, -d1, places comments one indentation lev- el to the left of code. -d0 lines up these com- ments with the code. See the section on comment indentation below. -br,-bl Specifying -bl will cause complex statements to be lined up like this: if (...) { code } Specifying -br (the default) will make them look like this: if (...) { code } You may set up your own ``profile'' of defaults to indent by creating the file .indent.pro in your home directory and in- cluding whatever switches you like. If indent is run and a profile file exists, then it is read to set up the program's defaults. Switches on the command line, though, will always override profile switches. The profile file must be a sin- gle line of not more than 127 characters. The switches should be separated on the line by spaces or tabs. Multiline Expressions indent will not break up complicated expressions that extend over multiple lines, but it will usually correctly indent such expressions which have already been broken up. Such an 2 April, 1990



indent(1) indent(1)
expression might end up looking like this: x = ( (Arbitrary parenthesized expression) + ( (Parenthesized expression) * (Parenthesized expression) ) ); Comments indent recognizes four kinds of comments. They are: straight text, box comments, UNIX-style comments, and comments that should be passed through unchanged. The action taken with these various types are as follows: Box comments. indent assumes that any comment with a dash immediately after the start of comment (i.e. /*-) is a com- ment surrounded by a box of stars. Each line of such a com- ment will be left unchanged, except that the first nonblank character of each successive line will be lined up with the beginning slash of the first line. Box comments will be in- dented (see below). UNIX-style comments. This is the type of section header which is used extensively in the UNIX system source. If the start of comment (/*) appears on a line by itself, indent assumes that it is a UNIX-style comment. These will be treated similarly to box comments, except the first nonblank character on each line will be lined up with the ``*'' of the /*. Unchanged comments. Any comment which starts in column 1 will be left completely unchanged. This is intended pri- marily for documentation header pages. The check for un- changed comments is made before the check for UNIX-style comments. Straight text. All other comments are treated as straight text. indent will fit as many words (separated by blanks, tabs, or newlines) on a line as possible. Straight text comments will be indented. Comment Indentation Box, UNIX-style, and straight text comments may be indented. If a comment is on a line with code it will be started in the comment column, which is set by the -cnnn command line parameter. Otherwise, the comment will be started at nnn indentation levels less than where code is currently being April, 1990 3



indent(1) indent(1)
placed, where nnn is specified by the -dnnn command line parameter. (Indented comments will never be placed in column 1.) If the code on a line extends past the comment column, the comment will be moved to the next line. DIAGNOSTICS Diagnostic error messages, mostly to tell that a text line has been broken or is too long for the output line. FILES /usr/ucb/indent ~/.indent.pro profile file SEE ALSO cb(1). BUGS Does not know how to format ``long'' declarations. 4 April, 1990

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026