Annotation of 43BSDTahoe/man/man1/indent.1, revision 1.1

1.1     ! root        1: .\" Copyright (c) 1983 Regents of the University of California.
        !             2: .\" All rights reserved.  The Berkeley software License Agreement
        !             3: .\" specifies the terms and conditions for redistribution.
        !             4: .\"
        !             5: .\"    @(#)indent.1    6.4 (Berkeley) 9/10/85
        !             6: .\"
        !             7: .TH INDENT 1 "September 10, 1985"
        !             8: .UC 5
        !             9: .SH NAME
        !            10: indent \- indent and format C program source
        !            11: .SH SYNOPSIS
        !            12: .in +\w'\fBindent \fR'u
        !            13: .ti -\w'\fBindent \fR'u
        !            14: \fBindent \fR [ \fIinput-file\fR [ \fIoutput-file\fR ] ]
        !            15: [\ \fB\-bad\fR\ |\ \fB\-nbad\fR\ ]
        !            16: [\ \fB\-bap\fR\ |\ \fB\-nbap\fR\ ]
        !            17: [\ \fB\-bbb\fR\ |\ \fB\-nbbb\fR\ ]
        !            18: [\ \fB\-bc\fR\ |\ \fB\-nbc\fR\ ]
        !            19: [\ \fB\-bl\fR\ |\ \fB\-br\fR\ ]
        !            20: [\ \fB\-c\fIn\fR\ ]
        !            21: [\ \fB\-cd\fIn\fR\ ]
        !            22: [\ \fB\-cdb\fR\ |\ \fB\-ncdb\fR\ ]
        !            23: [\ \fB\-ce\fR\ |\ \fB\-nce\fR\ ]
        !            24: [\ \fB\-ci\fIn\fR\ ]
        !            25: [\ \fB\-cli\fIn\fR\ ]
        !            26: [\ \fB\-d\fIn\fR\ ]
        !            27: [\ \fB\-di\fIn\fR\ ]
        !            28: [\ \fB\-dj\fR\ |\ \fB\-ndj\fR\ ]
        !            29: [\ \fB\-ei\fR\ |\ \fB\-nei\fR\ ]
        !            30: [\ \fB\-fc1\fR\ |\ \fB\-nfc1\fR\ ]
        !            31: [\ \fB\-i\fIn\fR\ ]
        !            32: [\ \fB\-ip\fR\ |\ \fB\-nip\fR\ ]
        !            33: [\ \fB\-l\fIn\fR\ ]
        !            34: [\ \fB\-lc\fIn\fR\ ]
        !            35: [\ \fB\-lp\fR\ |\ \fB\-nlp\fR\ ]
        !            36: [\ \fB\-npro\fR\ ]
        !            37: [\ \fB\-pcs\fR\ |\ \fB\-npcs\fR\ ]
        !            38: [\ \fB\-ps\fR\ |\ \fB\-nps\fR\ ]
        !            39: [\ \fB\-psl\fR\ |\ \fB\-npsl\fR\ ]
        !            40: [\ \fB\-sc\fR\ |\ \fB\-nsc\fR\ ]
        !            41: [\ \fB\-sob\fR\ |\ \fB\-nsob\fR\ ]
        !            42: [\ \fB\-st\fR\ ]
        !            43: [\ \fB\-troff\fR\ ]
        !            44: [\ \fB\-v\fR\ |\ \fB\-nv\fR\ ]
        !            45: .SH DESCRIPTION
        !            46: .IX  indent  ""  "\fLindent\fP \(em format C source"
        !            47: .IX  "programming tools"  "indent"  ""  "\fLindent\fP \(em format C source"
        !            48: .IX  "languages"  "indent"  ""  "\fLindent\fP \(em format C source"
        !            49: .IX  "C programming language"  "indent"  ""  "\fLindent\fP \(em format C source"
        !            50: .IX  "pretty printer"  "indent"  ""  "\fLindent\fP \(em format C source"
        !            51: .IX  "format C programs" "" "format C programs \(em \fLindent\fP"
        !            52: .IX  "code formatter"  "indent"  ""  "\fLindent\fP \(em format C source"
        !            53: .IX  "cb"  "indent"  "\fLcb\fP"  "try \fLindent\fP \(em format C source"
        !            54: .I Indent
        !            55: is a \fBC\fR program formatter.  It reformats the \fBC\fR program in the
        !            56: \fIinput-file\fR according to the switches.  The switches which can be
        !            57: specified are described below. They may appear before or after the file
        !            58: names.
        !            59: .LP
        !            60: \fBNOTE\fP: If you only specify an \fIinput-file\fR, the formatting is
        !            61: done `in-place', that is, the formatted file is written back into
        !            62: .I input-file
        !            63: and a backup copy of
        !            64: .I input-file
        !            65: is written in the current directory.  If
        !            66: .I input-file
        !            67: is named `/blah/blah/file', the backup file is named
        !            68: .RI file .BAK.
        !            69: .LP
        !            70: If
        !            71: .I output-file
        !            72: is specified,
        !            73: .I indent
        !            74: checks to make sure it is different from
        !            75: .IR input-file .
        !            76: .SH OPTIONS
        !            77: .LP
        !            78: The options listed below control the formatting style imposed by
        !            79: .IR indent .
        !            80: .TP 15
        !            81: .BR \-bad , \-nbad
        !            82: If
        !            83: .B \-bad
        !            84: is specified, a blank line is forced after every block of
        !            85: declarations.  Default:  
        !            86: .BR \-nbad .
        !            87: .TP 15
        !            88: .BR \-bap , \-nbap
        !            89: If
        !            90: .B \-bap
        !            91: is specified, a blank line is forced after every procedure body.  Default:
        !            92: .B \-nbap.
        !            93: .TP 15
        !            94: .BR \-bbb , \-nbbb
        !            95: If
        !            96: .B \-bbb
        !            97: is specified, a blank line is forced before every block comment.  Default:
        !            98: .B \-nbbb.
        !            99: .TP 15
        !           100: .BR \-bc , \-nbc
        !           101: If
        !           102: .B \-bc
        !           103: is specified, then a newline is forced after each comma in a declaration. 
        !           104: .B \-nbc
        !           105: turns off this option.  The default is
        !           106: .BR \-nbc .
        !           107: .TP 15
        !           108: .BR \-br , \-bl
        !           109: Specifying
        !           110: .B \-bl
        !           111: lines up compound statements like this:
        !           112: .ne 4
        !           113: .nf
        !           114: .ft L
        !           115:     if (...)
        !           116:     {
        !           117:         code
        !           118:     }
        !           119: .ft R
        !           120: .fi
        !           121: Specifying
        !           122: .B \-br
        !           123: (the default) makes them look like this:
        !           124: .ne 3
        !           125: .nf
        !           126: .ft L
        !           127:     if (...) {
        !           128:         code
        !           129:     }
        !           130: .ft R
        !           131: .fi
        !           132: .LP
        !           133: .TP 15
        !           134: .BI \-c n
        !           135: The column in which comments on code start.  The default is 33.  
        !           136: .TP 15
        !           137: .BI \-cd n
        !           138: The column in which comments on declarations start.  The default
        !           139: is for these comments to start in the same column as those on code.
        !           140: .TP 15
        !           141: .BI \-cdb , \-ncdb
        !           142: Enables (disables) the placement of comment delimiters on blank lines.  With
        !           143: this option enabled, comments look like this:
        !           144: .nf
        !           145: .ft L
        !           146: .ne 3
        !           147:        /*
        !           148:         * this is a comment
        !           149:         */
        !           150: .ft R
        !           151: .fi
        !           152: Rather than like this:
        !           153: .nf
        !           154: .ft L
        !           155:        /* this is a comment */
        !           156: .ft R
        !           157: .fi
        !           158: This only affects block comments, not comments to the right of
        !           159: code. The default is
        !           160: .BR \-cdb .
        !           161: .TP 15
        !           162: .BI \-ce , \-nce
        !           163: Enables (disables) forcing `else's to cuddle up to the immediately preceding
        !           164: `}'.  The default is
        !           165: .BR \-ce .
        !           166: .TP 15
        !           167: .BI \-ci n
        !           168: Sets the continuation indent to be \fIn\fR.  Continuation
        !           169: lines will be indented that far from the beginning of the first line of the
        !           170: statement.  Parenthesized expressions have extra indentation added to
        !           171: indicate the nesting, unless \fB\-lp\fR is in effect.
        !           172: \fB\-ci\fR defaults to the same value as \fB\-i\fR.
        !           173: .TP 15
        !           174: .BI \-cli n
        !           175: Causes case labels to be indented
        !           176: .I n
        !           177: tab stops to the right of the containing \fBswitch\fR statement.
        !           178: \fB\-cli0.5\fR causes case labels to be indented half a tab stop.  The
        !           179: default is
        !           180: .BR \-cli0 .
        !           181: (This is the only option that takes a fractional argument.)
        !           182: .TP 15
        !           183: .BI \-d n
        !           184: Controls the placement of comments which are not to the
        !           185: right of code.  Specifying
        !           186: .B \-d1
        !           187: means that such comments are placed one indentation level to the
        !           188: left of code.  The default
        !           189: .B \-d0
        !           190: lines up these comments with the code.  See the section on comment
        !           191: indentation below.
        !           192: .TP 15
        !           193: .BI \-di n
        !           194: Specifies the indentation, in character positions, from a declaration keyword
        !           195: to the following identifier.  The default is
        !           196: .BR \-di16 .
        !           197: .TP 15
        !           198: .BR \-dj , \-ndj
        !           199: .B \-dj
        !           200: left justifies declarations.
        !           201: .B \-ndj
        !           202: indents declarations the same as code.  The default is
        !           203: .BR \-ndj .
        !           204: .TP 15
        !           205: .BI \-ei , \-nei
        !           206: Enables (disables) special
        !           207: .B else-if
        !           208: processing.  If enabled,
        !           209: .BR if "s"
        !           210: following
        !           211: .BR else "s"
        !           212: will have the same indentation as the preceding
        !           213: .B if
        !           214: statement.  The default is
        !           215: .BR \-ei .
        !           216: .TP 15
        !           217: .BI \-fc1 , \-nfc1
        !           218: Enables (disables) the formatting of comments that start in column 1.
        !           219: Often, comments whose leading `/' is in column 1 have been carefully
        !           220: hand formatted by the programmer.  In such cases, \fB\-nfc1\fR should be
        !           221: used.  The default is \fB\-fc1\fR.
        !           222: .TP 15
        !           223: .BI \-i n
        !           224: The number of spaces for one indentation level.  The default is 8.
        !           225: .TP 15
        !           226: .BI \-ip , \-nip
        !           227: Enables (disables) the indentation of parameter declarations from the left
        !           228: margin.  The default is
        !           229: .BR \-ip .
        !           230: .TP 15
        !           231: .BI \-l n
        !           232: Maximum length of an output line.  The default is 78.
        !           233: .TP 15
        !           234: .BI \-lp , \-nlp
        !           235: Lines up code surrounded by parenthesis in continuation lines.  If a line
        !           236: has a left paren which is not closed on that line, then continuation lines
        !           237: will be lined up to start at the character position just after the left
        !           238: paren.  For example, here is how a piece of continued code looks with
        !           239: \fB\-nlp\fR in effect:
        !           240: .ne 2
        !           241: .nf
        !           242: .ft L
        !           243:     p1 = first_procedure(second_procedure(p2, p3),
        !           244:         third_procedure(p4, p5));
        !           245: .ft R
        !           246: .fi
        !           247: .ne 5
        !           248: With \fB\-lp\fR in effect (the default) the code looks somewhat clearer:
        !           249: .nf
        !           250: .ft L
        !           251: .ta \w'    p1 = first_procedure('u
        !           252:     p1 = first_procedure(second_procedure(p2, p3),
        !           253:        third_procedure(p4, p5));
        !           254: .ft R
        !           255: .fi
        !           256: .ne 5
        !           257: Inserting two more newlines we get:
        !           258: .nf
        !           259: .ft L
        !           260: .ta \w'    p1 = first_procedure('u +\w'second_procedure('u
        !           261:     p1 = first_procedure(second_procedure(p2,
        !           262:                p3),
        !           263: .ta \w'    p1 = first_procedure('u +\w'third_procedure('u
        !           264:        third_procedure(p4,
        !           265:                p5));
        !           266: .ft R
        !           267: .fi
        !           268: .TP 15
        !           269: .B \-npro
        !           270: Causes the profile files, `./.indent.pro' and `~/.indent.pro', to be ignored.
        !           271: .TP 15
        !           272: .BR \-pcs , \-npcs
        !           273: If true (\fB\-pcs\fR) all procedure calls will have a space inserted between
        !           274: the name and the `('.  The default is 
        !           275: .BR \-npcs .
        !           276: .TP 15
        !           277: .BR \-ps , \-nps
        !           278: If true (\fB\-ps\fR) the pointer following operator `\->' will be
        !           279: surrounded by spaces on either side.  The default is
        !           280: .BR \-nps .
        !           281: .TP 15
        !           282: .BR \-psl , \-npsl
        !           283: If true (\fB\-psl\fR) the names of procedures being defined are placed in
        !           284: column 1 \- their types, if any, will be left on the previous lines.  The
        !           285: default is 
        !           286: .BR \-psl .
        !           287: .TP 15
        !           288: .BR \-sc , \-nsc
        !           289: Enables (disables) the placement of asterisks (`*'s) at the left edge of all
        !           290: comments.  The default is
        !           291: .BR \-sc .
        !           292: .TP 15
        !           293: .BR \-sob , \-nsob
        !           294: If
        !           295: .B \-sob
        !           296: is specified, indent will swallow optional blank lines.  You can use this to
        !           297: get rid of blank lines after declarations.  Default:
        !           298: .BR \-nsob .
        !           299: .TP 15
        !           300: .B \-st
        !           301: Causes
        !           302: .B indent
        !           303: to take its input from stdin, and put its output to stdout.
        !           304: .TP 15
        !           305: .BI \-T typename
        !           306: Adds
        !           307: .I typename
        !           308: to the list of type keywords.  Names accumulate:
        !           309: .B \-T
        !           310: can be specified more than once.  You need to specify all the typenames that
        !           311: appear in your program that are defined by \fBtypedef\fRs \- nothing will be
        !           312: harmed if you miss a few, but the program won't be formatted as nicely as
        !           313: it should.  This sounds like a painful thing to have to do, but it's really
        !           314: a symptom of a problem in C: \fBtypedef\fR causes a syntactic change in the
        !           315: language and \fIindent\fR can't find all \fBtypedef\fRs.
        !           316: .TP 15
        !           317: .B \-troff
        !           318: Causes
        !           319: .B indent
        !           320: to format the program for processing by troff.  It will produce a fancy
        !           321: listing in much the same spirit as
        !           322: .BR vgrind .
        !           323: If the output file is not specified, the default is standard output,
        !           324: rather than formatting in place.
        !           325: .TP 15
        !           326: .BR \-v , \-nv
        !           327: .B \-v
        !           328: turns on `verbose' mode;
        !           329: .B \-nv
        !           330: turns it off.  When in verbose mode,
        !           331: .I indent
        !           332: reports when it splits one line of input into two or more lines of output,
        !           333: and gives some size statistics at completion. The default is
        !           334: .BR \-nv .
        !           335: .SH "FURTHER DESCRIPTION"
        !           336: .LP
        !           337: You may set up your own `profile' of defaults to
        !           338: .I indent
        !           339: by creating a file called
        !           340: .BI . indent . pro
        !           341: in either your login directory and/or the current directory and including
        !           342: whatever switches you like.  Switches in `.indent.pro' in the current
        !           343: directory override those in your login directory (with the exception of
        !           344: .B -T
        !           345: type definitions, which just accumulate).  If
        !           346: .I indent
        !           347: is run and a profile file exists, then it is read to set up the program's
        !           348: defaults.  The switches should be separated by spaces, tabs or newlines.
        !           349: Switches on the command line, however, override profile switches.
        !           350: .LP
        !           351: .B Comments
        !           352: .LP
        !           353: .IR "`Box' comments" .
        !           354: .I Indent
        !           355: assumes that any comment with a dash or star immediately after the start of
        !           356: comment (that is, `/*\-' or `/**') is a comment surrounded by a box of stars.
        !           357: Each line of such a comment is left unchanged, except that its indentation
        !           358: may be adjusted to account for the change in indentation of the first line
        !           359: of the comment.
        !           360: .LP
        !           361: .IR "Straight text" .
        !           362: All other comments are treated as straight text.
        !           363: .I Indent
        !           364: fits as many words (separated by blanks, tabs, or newlines) on a
        !           365: line as possible.  Blank lines break paragraphs.
        !           366: .LP
        !           367: .B Comment indentation
        !           368: .LP
        !           369: If a comment is on a line with code it is started in the `comment column',
        !           370: which is set by the
        !           371: .BI \-c n
        !           372: command line parameter.  Otherwise, the comment is started at
        !           373: .I n
        !           374: indentation levels less than where code is currently being placed, where
        !           375: .I n
        !           376: is specified by the
        !           377: .BI \-d n
        !           378: command line parameter.  If the code on a line extends past the comment
        !           379: column, the comment starts further to the right, and the right margin may be
        !           380: automatically extended in extreme cases.
        !           381: .LP
        !           382: .B Preprocessor lines
        !           383: .LP
        !           384: In general, \fIindent\fR leaves preprocessor lines alone.  The only
        !           385: reformatting that it will do is to straighten up trailing comments.  It
        !           386: leaves embedded comments alone.  Conditional compilation
        !           387: (\fB#ifdef...#endif\fR) is recognized and \fIindent\fR attempts to correctly
        !           388: compensate for the syntactic peculiarities introduced.
        !           389: .LP
        !           390: .B C syntax
        !           391: .LP
        !           392: \fIIndent\fR understands a substantial amount about the syntax of C, but it
        !           393: has a `forgiving' parser.  It attempts to cope with the usual sorts of
        !           394: incomplete and misformed syntax.  In particular, the use of macros like:
        !           395: .nf
        !           396: .ft L
        !           397:         #define forever for(;;)
        !           398: .ft R
        !           399: .fi
        !           400: is handled properly.
        !           401: .SH FILES
        !           402: .DT
        !           403: .br
        !           404: \&./.indent.pro        profile file
        !           405: .br
        !           406: ~/.indent.pro  profile file
        !           407: .SH BUGS
        !           408: .I Indent
        !           409: has even more switches than \fIls\fR.
        !           410: .sp
        !           411: .ne 5
        !           412: A common mistake that often causes grief is typing:
        !           413: .nf
        !           414: .ft L
        !           415:     indent *.c
        !           416: .ft R
        !           417: .fi
        !           418: to the shell in an attempt to indent all the \fBC\fR programs in a directory.
        !           419: This is probably a bug, not a feature.

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.