Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ indent.bsd(1) — Domain/IX SR9.5

Media Vault

Software Library

Restoration Projects

Artifacts Sought

INDENT(1)

NAME

indent − indent and format C program source

USAGE

indent input [ output ] [ options ]

DESCRIPTION

Indent is primarily a C program formatter that performs the following:

•indents code lines

•aligns comments

•inserts spaces around operators where necessary

•breaks up declaration lists as in “int a,b,c;”

Indent does not break up long statements to make them fit within the maximum line length, but it will flag lines that are too long.  It breaks lines so that each statement starts a new line, and braces appear alone on a line.  Indent also attempts to line up identifiers in declarations. 

The options below may appear before or after the filenames.  If the output file is omitted, indent writes the formatted file back into input, and then a back-up copy of input into the current directory.  If input is named /directory/subdirectory/file, the back-up file is named .Bfile.  If output is specified, indent checks to make sure it is different from input.

You may set up an individual profile of defaults to indent by creating the file .indent.pro in your log-in directory, and including the desired switches.  If indent encounters a profile file during its run, it reads the file to set up the program’s defaults.  Switches on the command line, though, always override profile switches.  The profile file must be a single line of not more than 127 characters.  Separate the switches on the line by spaces or tabs. 

OPTIONS

−lnnn Change the length of an output line to a maximum of nnn. The default is 75.

−cnnn Start comments in column nnn. The default is 33.

−cdnnn Start comments on declarations in column nnn. The default is for these comments to start in the same column as other comments.

−innn Set the number of spaces for one indentation level to nnn. The default is four.

−dj Left-justify all declarations. 

−ndj Indent all declarations the same number of spaces as the code is indented. This is the default. 

−v Report when one line of input gets split into two or more lines of output.  Provide size statistics at completion. 

−nv Silence all messages supplied by the −v option.  This is the default. 

−bc Force a newline after each comma in a declaration. This is the default. 

−nbc Do not force a newline after each comma in a declaration. 

−dnnn Place comments that are not to the right of code on a line nnn indentation levels to the left of the code.  The default −d0 aligns these comments with the code. 

−bl Line up complex statements in the following manner:

    if (...)
    {
        code
    }

−br Line up complex statements in the following manner (this is the default):

    if (...) {
        code
    }

MULTI-LINE EXPRESSIONS

Indent does not break up complicated expressions that extend over multiple lines.  Under most circumstances, however, it correctly indents expressions that have already been broken up.  Such an expression might end up looking like this:

x =
        (
            (Arbitrary parenthesized expression)
            +
            (
                (Parenthesized expression)
                *
                (Parenthesized expression)
            )
        );
 

COMMENT TYPES

Box Indent assumes that any comment with a dash immediately after the start of a comment (i.e., /*−) is a comment surrounded by a box of stars.  Each line of such a comment is left unchanged, except that the first nonblank character of each successive line is lined up with the beginning slash of the first line.  Box comments are indented (see below). 

“UNIX-style” This is the type of section header that is used extensively in the UNIX system source.  If the start of a comment (/*) appears on a line by itself, indent assumes that it is a UNIX-style comment.  Although they are treated similarly to box comments, UNIX-style comments have the first nonblank character of each line aligned with the asterisk in the start of comment (/*). 

Unchanged Any comment that starts in column 1 is left completely unchanged.  This is intended primarily for documentation header pages.  The check for unchanged comments is made before the check for UNIX-style comments. 

Straight text All other comments are treated as straight text.  Indent tries to fit as many words separated by blanks, tabs, or newlines as possible on a line. 

COMMENT INDENTATION

Box, UNIX-style, and straight text comments may be indented.  If a comment is on a line with code it is started in the comment column, which is set by the −cnnn command line parameter.  Otherwise, the comment is started at nnn indentation levels less than where code is currently being placed (where nnn is specified by the −dnnn command line parameter).  Indented comments are never placed in column 1.  If the code on a line extends past the comment column, the comment is moved to the next line. 

CAUTIONS

Indent does not know how to format long declarations. 

FILES

~/indent.proprofile file

DIAGNOSTICS

Diagnostic error messages, mainly to tell that a text line has been broken or is too long for the output line. 

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