Commit | Line | Data |
---|---|---|
331ce6fe DW |
1 | .TH INDENT 1 "22 December 1977" |
2 | .UC 4 | |
3 | .SH NAME | |
4 | indent \- indent and format a C program source | |
5 | .SH SYNOPSIS | |
6 | indent ifile [ ofile ] [ args ] | |
7 | .SH DESCRIPTION | |
8 | The arguments that can be specified follows. They | |
9 | may appear before or after the file names. | |
10 | ||
11 | .TP 10 | |
12 | .B ifile | |
13 | Input file specification. | |
14 | .TP 10 | |
15 | .B ofile | |
16 | Output file specification. | |
17 | .br | |
18 | If omitted, then the indented formatted file will be written | |
19 | back into the input file, | |
20 | and there will be a "back\-up" copy of ifile written | |
21 | in the current directory. | |
22 | For an ifile named "/blah/blah/file", the backup file will be | |
23 | named ".Bfile". (It will only be listed when the `\-a' argument | |
24 | is specified in ls.) | |
25 | If ofile is specified, indent checks to make sure it is different from ifile. | |
26 | .TP 10 | |
27 | .B \-lnnn | |
28 | Maximum length of an output line. The default is 75. | |
29 | .TP 10 | |
30 | .B \-cnnn | |
31 | The column in which comments will start. The default is 33. | |
32 | .TP 10 | |
33 | .B \-cdnnn | |
34 | The column in which comments on declarations will start. The default | |
35 | is for these comments to start in the same column as other comments. | |
36 | .TP 10 | |
37 | .B \-innn | |
38 | The number of spaces for one indentation level. The default is 4. | |
39 | .TP 10 | |
40 | .B \-dj,\-ndj | |
41 | \-dj will cause declarations to be left justified. \-ndj will cause | |
42 | them to be indented the same as code. The default is \-ndj. | |
43 | .TP 10 | |
44 | .B \-v,\-nv | |
45 | \-v turns on "verbose" mode, \-nv turns it off. When in verbose | |
46 | mode, indent will report when it | |
47 | splits one line of input into two or more lines of output, | |
48 | and it will give some size statistics at completion. The default is \-nv. | |
49 | .TP 10 | |
50 | .B \-bc,\-nbc | |
51 | If \-bc is specified, then a newline will be forced after each | |
52 | comma in a declaration. \-nbc will turn off this option. The default is \-bc. | |
53 | .TP 10 | |
54 | .B \-dnnn | |
55 | This option controls the placement of comments which are not to the right | |
56 | of code. | |
57 | Specifying \-d2 means that such comments will be placed two | |
58 | indentation levels to the left of code. | |
59 | The default \-d0 lines up these comments with the code. | |
60 | See the section on comment indentation below. | |
61 | .TP 10 | |
62 | .B \-br,\-bl | |
63 | Specifying \-bl will cause | |
64 | complex statements to be lined up like this: | |
65 | .ne 4 | |
66 | .nf | |
67 | if (...) | |
68 | { | |
69 | code | |
70 | } | |
71 | .fi | |
72 | Specifying \-br (the default) will make them look like this: | |
73 | .ne 3 | |
74 | .nf | |
75 | if (...) { | |
76 | code | |
77 | } | |
78 | .fi | |
79 | .PP | |
80 | You may set up your own `profile' of defaults to indent | |
81 | by creating the file `/usr/your\-name/.indent.pro' | |
82 | (where your\-name is your | |
83 | login name) | |
84 | and including whatever switches you like. | |
85 | If indent is run and a profile file exists, then it is read | |
86 | to set up the program's defaults. | |
87 | Switches on the command line, though, | |
88 | will always over\-ride profile switches. | |
89 | The profile | |
90 | file must be a single line of not more than 127 characters. | |
91 | The switches should be seperated on the line by spaces or tabs. | |
92 | Indent is intended primarily as a C program indenter. | |
93 | Specifically, indent will: | |
94 | .IP " >" 5 | |
95 | indent code lines | |
96 | .IP " >" 5 | |
97 | align comments | |
98 | .IP " >" 5 | |
99 | insert spaces around operators where necessary | |
100 | .IP " >" 5 | |
101 | break up declaration lists as in "int a,b,c;". | |
102 | .PP | |
103 | It will not break up long statements to make them fit within the | |
104 | maximum line length, but it will flag lines that are too long. Lines | |
105 | will be broken so that each statement starts a new line, and braces | |
106 | will appear alone on a line. (See the \-br option to inhibit this.) | |
107 | Also, an attempt is made to line up identifiers in declarations. | |
108 | ||
109 | Multi\-line expressions | |
110 | .br | |
111 | Indent will not break up complicated expressions that extend over multiple | |
112 | lines, but it will usually correctly indent such expressions which have | |
113 | already been broken up. Such an expression might end up looking like this: | |
114 | .ne 10 | |
115 | .in +4 | |
116 | .nf | |
117 | x = | |
118 | ( | |
119 | (Arbitrary parenthesized expression) | |
120 | + | |
121 | ( | |
122 | (Parenthesized expression) | |
123 | * | |
124 | (Parenthesized expression) | |
125 | ) | |
126 | ); | |
127 | ||
128 | .fi | |
129 | .PP | |
130 | Comments | |
131 | .br | |
132 | Indent recognizes four kinds of comments. They are straight text, "box" comments, | |
133 | UNIX\-style comments, | |
134 | and comments that should be passed thru unchanged. The action taken with these | |
135 | various types is as follows: | |
136 | ||
137 | "Box" comments: The DSG documentation standards specify that boxes will be | |
138 | placed around section headers. Indent assumes that any comment with a dash | |
139 | immediately after the start of comment (i.e. "/*\-") is such a box. Each line | |
140 | of such a comment will be left unchanged, except that the first non\-blank | |
141 | character of each successive line will be lined up with the beginning | |
142 | slash of the first line. Box comments will be indented (see below). | |
143 | ||
144 | Unix\-style comments: This is the type of section header which is used | |
145 | extensively in the UNIX system source. If the start of comment ('/*') appears on a | |
146 | line by itself, indent assumes that it is a UNIX\-style comment. These will be | |
147 | treated similarly to box comments, except the first non\-blank character on each | |
148 | line will be lined up with the '*' of the '/*'. | |
149 | ||
150 | Unchanged comments: Any comment which starts in column 1 will be left completely | |
151 | unchanged. This is intended primarily for documentation header pages. | |
152 | The check for unchanged comments is made before the check for UNIX\-style comments. | |
153 | ||
154 | Straight text: All other comments are treated as straight text. Indent will fit | |
155 | as many words (separated by blanks, tabs, or newlines) on a line as possible. | |
156 | Straight text comments will be indented. | |
157 | ||
158 | Comment indentation | |
159 | Box, UNIX\-style, and straight text comments may be indented. | |
160 | If a comment is on a line | |
161 | with code it will be started in the "comment | |
162 | column", which is set by the \-cnnn command line parameter. | |
163 | Otherwise, the | |
164 | comment will be started at nnn indentation levels less than where code is | |
165 | currently being placed, where nnn is specified by the \-dnnn command line parameter. (Indented | |
166 | comments will never be placed in column 1.) | |
167 | If the code on a line extends past the comment column, the comment will be moved | |
168 | to the next line. | |
169 | ||
170 | .SH DIAGNOSTICS | |
171 | Diagnostic error messsages, mostly to tell that a text line has been broken | |
172 | or is too long for the output line, will be printed on the controlling tty. | |
173 | .SH FILES | |
174 | /usr/your\-name/.indent.pro \- profile file | |
175 | .SH BUGS | |
176 | Doesn't know how to format "long" declarations. |