📄 indent.9
字号:
.CD "indent \(en reformat the layout of a program".SX "indent \fIin_file\fR [\fIout_file\fR] [\fIoptions\fR].FL "\fR(many)".EX "indent \(enbr \(enc25 prog.c " "Indent \fIprog.c\fR.EX "indent \(ennpcs prog.c newprog.c" "Put output on \fInewprog.c".PP\fIIndent\fR reads a C program in, rearranges the layout, and outputs anew C program that will compile to the same executable binary as the originalone.The difference between the input and output is that the output is in a standardlayout determined by a large number of options.For most of the options there are two choices, one that enables it and onethat disables it..PPIf \fIindent\fR is called with no file files, it operates as a filter.If called with one file name, that file is reformatted and the resultreplaces the original file.A backup is created, however, with the suffix \fI.BAK\fR.If it is called with two file names, the first one is the input file andthe second one is the output file.Only one file can be reformatted at a time (e.g., one cannot call \fIindent\fRwith *.c as argument; this is an error and will not work.)..SS "Options".PPMany options are available.If you want to format a program to the \*(OQofficial\*(CQ MINIX format, use \fIpretty\fR, which calls \fIindent\fR with the proper options and thenpostprocesses the output.The options listed below control the formatting style.OPTION: \fB\(enbad\fR, \fB\(ennbad\fR.PPIf \fB\(enbad\fR is specified, a blank line is forcedafter every block of declarations. Default: \fB\(ennbad\fR.OPTION: \fB\(enbap\fR, \fB\(ennbap\fR.PPIf \fB\(enbap\fR is specified, a blank line is forcedafter every procedure body. Default: \fB\(ennbap\fR.OPTION: \fB\(enbbb\fR, \fB\(ennbbb\fR.PPIf \fB\(enbbb\fR is specified, a blank line is forcedbefore every block comment. Default: \fB\(ennbbb\fR.OPTION: \fB\(enbc\fR, \fB\(ennbc\fR.PPIf \fB\(enbc\fR is specified, then a newline is forcedafter each comma in a declaration. \fB\(ennbc\fR turnsoff this option. The default is \fB\(ennbc\fR.OPTION: \fB\(enbl\fR, \fB\(enbr\fR.PPSpecifying \fB\(enbl\fR lines up compound statementslike this:.HS if (...) { code }.HSSpecifying \fB\(enbr\fR (the default) makes them looklike this:.HS if (...) { code }.HSOPTION: \fB\(enc\fIn\fR.PPThe column in which comments on code start.The default is 33.OPTION: \fB\(encd\fIn\fR.PPThe column in which comments on declarationsstart. The default is for these comments tostart in the same column as those on code.OPTION: \fB\(encdb\fR, \fB\(enncdb\fR.PPEnables (disables) the placement of commentdelimiters on blank lines. With this optionenabled, comments look like this:.HS /* * this is a comment */.HSRather than like this:.HS /* this is a comment */.HSThis only affects block comments, not comments to the right of code. The default is \fB\(encdb\fR.OPTION: \fB\(ence\fR, \fB\(ennce\fR.PPEnables (disables) forcing \*(OQelse\*(CQs to cuddleup to the immediately preceding \*(OQ}\*(CQ. Thedefault is \fB\(ence\fR.OPTION: \fB\(enci\fIn\fR.PPSets the continuation indent to be \fIn\fR. Continuation lines will be indented that far from the beginning of the first line of thestatement. Parenthesized expressions haveextra indentation added to indicate the nesting, unless \fB\(enlp\fR is in effect. \fB\(enci\fR defaultsto the same value as \fB\(eni\fR.OPTION: \fB\(encli\fIn\fR.PPCauses case labels to be indented \fIn\fR tab stopsto the right of the containing switch statement. \fB\(encli\fR0.5 causes case labels to beindented half a tab stop. The default is \fB\(encli\fR0. (This is the only option that takes a fractional argument.)OPTION: \fB\(end\fI\s+2n\s0\fR.PPControls the placement of comments which arenot to the right of code. Specifying \fB\(end\fR1means that such comments are placed oneindentation level to the left of code. Thedefault \fB\(end\fR0 lines up these comments with thecode. See the section on comment indentationbelow.OPTION: \fB\(endi\fI\s+2n\s0\fR.PPSpecifies the indentation, in character positions, from a declaration keyword to the following identifier. The default is \fB\(endi\fR16.OPTION: \fB\(endj\fR, \fB\(enndj\fR.PP\fB\(endj\fR left justifies declarations. \fB\(enndj\fRindents declarations the same as code. Thedefault is \fB\(enndj\fR.OPTION: \fB\(enei\fR, \fB\(ennei\fR.PPEnables (disables) special else\fB\(enif\fR processing. If enabled, ifs following elses willhave the same indentation as the preceding ifstatement. The default is \fB\(enei\fR.OPTION: \fB\(enfc\fR1, \fB\(ennfc\fR1.PPEnables (disables) the formatting of commentsthat start in column 1. Often, commentswhose leading \*(OQ/\*(CQ is in column 1 have beencarefully hand formatted by the programmer.In such cases, \fB\(ennfc\fR1 should be used. Thedefault is \fB\(enfc\fR1.OPTION: \fB\(eni\fI\s+1n\s0\fR.PPThe number of spaces for one indentationlevel. The default is 8.OPTION: \fB\(enip\fR, \fB\(ennip\fR.PPEnables (disables) the indentation of parameter declarations from the left margin. The default is \fB\(enip\fR.OPTION: \fB\(enln\fR.PPMaximum length of an output line. The default is 78.OPTION: \fB\(enlp\fR, \fB\(ennlp\fR.PPLines up code surrounded by parenthesis incontinuation lines. If a line has a leftparen which is not closed on that line, thencontinuation lines will be lined up to startat the character position just after the leftparen. OPTION: \fB\(ennpro\fR.PPCauses the profile files, \fI.indent.pro\fR in both the current directoryand the user's home directory to be ignored.OPTION: \fB\(enpcs\fR, \fB\(ennpcs\fR.PPIf true (\fB\(enpcs\fR) all procedure calls will havea space inserted between the name and the \*(OQ(\*(CQ. The default is \fB\(ennpcs\fR.OPTION: \fB\(enps\fR, \fB\(ennps\fR.PPIf true (\fB\(enps\fR) the pointer following operator \*(OQ\(en>\*(CQ will be surrounded by spaces on either side. The default is \fB\(ennps\fR.OPTION: \fB\(enpsl\fR, \fB\(ennpsl\fR.PPIf true (\fB\(enpsl\fR) the names of procedures beingdefined are placed in column 1 \(en their types,if any, will be left on the previous lines.The default is \fB\(enpsl\fR.OPTION: \fB\(ensc\fR, \fB\(ennsc\fR.PPEnables (disables) the placement of asterisks(*) at the left edge of all comments. The default is \fB\(ensc\fR.OPTION: \fB\(ensob\fR, \fB\(ennsob\fR.PPIf \fB\(ensob\fR is specified, \fIindent\fR will swallowoptional blank lines. You can use this toget rid of blank lines after declarations. The default is \fB\(ennsob\fR.OPTION: \fB\(enst\fR.PPCauses \fIindent\fR to take its input from \fIstdin\fR, and put its output to \fIstdout\fR.OPTION: \fB\(enT\fItypename\fR.PPAdds typename to the list of type keywords.Names accumulate: \fB\(enT\fR can be specified morethan once. You need to specify all thetypenames that appear in your program thatare defined by #typedefs. Nothing will beharmed if you miss a few, but the programwill not be formatted as nicely as it should.This sounds like a painful thing to have todo, but it is really a symptom of a problem inC: typedef causes a syntactic change in thelanguage and \fIindent\fR cannot find all typedefs.OPTION: \fB\(entroff\fR.PPCauses \fIindent\fR to format the program for processing by \fItroff\fR. It will produce a fancy listing in much the same spirit as \fIvgrind\fR.If the output file is not specified, thedefault is standard output, rather than formatting in place.OPTION: \fB\(env\fR, \fB\(ennv\fR.PPThe \fB\(env\fR flag turns on verbose mode; \fB\(ennv\fR turns it off.When in verbose mode, \fIindent\fR reports when itsplits one line of input into two or morelines of output, and gives some size statistics at completion. The default is \fB\(ennv\fR..SS "User Profiles".PPYou may set up your own profile of defaults to \fIindent\fR bycreating a file called \fI.indent.pro\fR in either your logindirectory and/or the current directory and including whatever switches you like. Switches in \fI.indent.pro\fR in thecurrent directory override those in your login directory(with the exception of \fB\(enT\fR type definitions, which just accumulate). If \fIindent\fR is run and a profile file exists, thenit is read to set up the program's defaults. The switchesshould be separated by spaces, tabs or newlines. Switcheson the command line, however, override profile switches..SS "Comments".PP\fIIndent\fR assumes that any comment with a dashor star immediately after the start of comment (that is, \*(OQ/*\(en\*(CQ or \*(OQ/**\*(CQ) is a comment surrounded by a box of stars.Each line of such a comment is left unchanged, except thatits indentation may be adjusted to account for the change inindentation of the first line of the comment..PPAll other comments are treated as straighttext. Indent fits as many words (separated by blanks, tabs,or newlines) on a line as possible. Blank lines break paragraphs..PPIf a comment is on a line with code it is started in thecomment column, which is set by the \fB\(encn\fR command lineparameter. Otherwise, the comment is started at \fIn\fR indentation levels less than where code is currently being placed,where n is specified by the \fB\(endn\fR command line parameter. Ifthe code on a line extends past the comment column, the comment starts further to the right, and the right margin maybe automatically extended in extreme cases..SS "Preprocessor Lines".PPIn general, \fIindent\fR leaves preprocessor lines alone. Theonly reformatting that it will do is to straighten up trailing comments. It leaves embedded comments alone. Conditional compilation (#ifdef...#endif) is recognized and\fIindent\fR attempts to correctly compensate for the syntacticpeculiarities introduced..SS "C Syntax".PPIndent understands a substantial amount about the syntax ofC, but it has a forgiving parser. It attempts to copewith the usual sorts of incomplete and misformed syntax. Inparticular, the use of macros like:.HS #define forever for(;;).HSis handled properly.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -