Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ indent(1) — SunOS 0.4

Media Vault

Software Library

Restoration Projects

Artifacts Sought

INDENT(1)  —  User’s Manual — Commands

NAME

indent − indent and format a C program source

SYNOPSIS

indent infile [ outfile ] [ options ]

DESCRIPTION

infile Input file specification. 

outfile Output file specification.  If outfile is omitted, the indented formatted file will be written back into the input file, and there will be a ‘back−up’ copy of infile written in the current directory.  For an infile named /blah/blah/file, the back−up file will be named .Bfile (It will only be listed when the −a option to ls is used).  If outfile is specified, indent checks to make sure it is different from infile. 

Options for indent are as follows.  They may appear before or after the input and output filenames. 

−lnnn Maximum length of an output line.  Default is 75 characters. 

−cnnn The column in which comments will start.  Default is 33 characters. 

−cdnnn The column in which comments on declarations will start.  By default, such comments start in the same column as other comments. 

−innn The number of spaces for one indentation level.  The default is 4. 

−dj,−ndj −dj left justifies declarations.  −ndj indents declarations to the same position as code.  The default is −ndj. 

−v,−nv −v turns on ‘verbose’ mode; −nv turns it off.  When in verbose mode, indent reports when it splits one line of input into two or more lines of output, and it gives some size statistics at completion.  The default is −nv. 

−bc,−nbc
−bc forces a newline after each comma in a declaration. 

−dnnn This option controls the placement of comments which are not to the right of code.  −d2 places such comments two indentation levels to the left of code.  The default −d0 lines up these comments with the code.  See the section on comment indentation below. 

−br,−bl −bl lines complex statements up like this:

    if (...)
    {
        code
    }

−br (the default) makes them look like this:

    if (...) {
        code
    }

You may set up your own ‘profile’ of defaults to indent by creating the file /usr/your−name/.indent.pro (where your−name is your login name) and including whatever switches you like.  If a profile file exists when you use indent, defaults are taken from this file.  The profile file must be a single line of not more than 127 characters; switches should be separated on the line by spaces or tabs.  Switches on the command line, though, will always over−ride profile switches. 

Indent is intended primarily as a C program indenter.  Specifically, indent will:

   ∗Indent code lines

   ∗Align comments

   ∗Insert spaces around operators where necessary

   ∗Break up declaration lists as in "int a,b,c;". 

It 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, and braces will appear alone on a line.  (See the −br option to inhibit this.)  Also, an attempt is made to line up identifiers in declarations. 

Multi−line 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 expression might end up looking like this:

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

Comments
Indent recognizes four kinds of comments:  ‘box’ comments, UNIX−style comments, comments that should be passed through unchanged, and straight text.  The action taken with these various types is as follows:

‘Box’ comments:
DSG documentation standards specify that boxes should be placed around section headers.  Indent assumes that any comment with a dash immediately after the start of comment (that is, ‘/∗−’) is such a box.  Each line of such a comment is left unchanged, except that the first non−blank character of each successive line is lined up with the beginning slash of the first line.  Box comments are indented (see below). 

Unix−style comments:
This type of section header 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 are treated as box comments, except the first non−blank character on each line is lined up with the ‘∗’ of the ‘/∗’. 

Unchanged comments:
Comments which start in column 1 are 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 fits as many words (separated by blanks, tabs, or newlines) on a line as possible.  Straight text comments are indented. 

Comment Indentation
Box, UNIX−style, and straight text comments may be indented. A comment which appears on the same line as code, is started in the ‘comment column’ set by the −cnnn option.  A comment which does not appear on the same line as code is started at nnn indentation levels less than the current position of code, where nnn is specified by the −dnnn option.  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. 

DIAGNOSTICS

Indent displays messages to tell you that, for example, a text line has been broken, or is too long. 

FILES

/usr/your−name/.indent.pro − profile file

BUGS

Doesn’t know how to format ‘long’ declarations. 

Sun System Release 0.3  —  22 March 1983

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