INDENT.9
资源名称:os_source.zip [点击查看]
上传用户:datang2001
上传日期:2007-02-01
资源大小:53269k
文件大小:10k
源码类别:
操作系统开发
开发平台:
C/C++
- .CD "indent (en reformat the layout of a program"
- .SX "indent fIin_filefR [fIout_filefR] [fIoptionsfR]
- .FL "fR(many)"
- .EX "indent (enbr (enc25 prog.c " "Indent fIprog.cfR
- .EX "indent (ennpcs prog.c newprog.c" "Put output on fInewprog.c"
- .PP
- fIIndentfR reads a C program in, rearranges the layout, and outputs a
- new C program that will compile to the same executable binary as the original
- one.
- The difference between the input and output is that the output is in a standard
- layout determined by a large number of options.
- For most of the options there are two choices, one that enables it and one
- that disables it.
- .PP
- If fIindentfR is called with no file files, it operates as a filter.
- If called with one file name, that file is reformatted and the result
- replaces the original file.
- A backup is created, however, with the suffix fI.BAKfR.
- If it is called with two file names, the first one is the input file and
- the second one is the output file.
- Only one file can be reformatted at a time (e.g., one cannot call fIindentfR
- with *.c as argument; this is an error and will not work.).
- .SS "Options"
- .PP
- Many options are available.
- If you want to format a program to the *(OQofficial*(CQ MINIX format, use
- fIprettyfR, which calls fIindentfR with the proper options and then
- postprocesses the output.
- The options listed below control the formatting style.
- OPTION: fB(enbadfR, fB(ennbadfR
- .PP
- If fB(enbadfR is specified, a blank line is forced
- after every block of declarations. Default: fB(ennbadfR.
- OPTION: fB(enbapfR, fB(ennbapfR
- .PP
- If fB(enbapfR is specified, a blank line is forced
- after every procedure body. Default: fB(ennbapfR.
- OPTION: fB(enbbbfR, fB(ennbbbfR
- .PP
- If fB(enbbbfR is specified, a blank line is forced
- before every block comment. Default: fB(ennbbbfR.
- OPTION: fB(enbcfR, fB(ennbcfR
- .PP
- If fB(enbcfR is specified, then a newline is forced
- after each comma in a declaration. fB(ennbcfR turns
- off this option. The default is fB(ennbcfR.
- OPTION: fB(enblfR, fB(enbrfR
- .PP
- Specifying fB(enblfR lines up compound statements
- like this:
- .HS
- if (...)
- {
- code
- }
- .HS
- Specifying fB(enbrfR (the default) makes them look
- like this:
- .HS
- if (...) {
- code
- }
- .HS
- OPTION: fB(encfInfR
- .PP
- The column in which comments on code start.
- The default is 33.
- OPTION: fB(encdfInfR
- .PP
- The column in which comments on declarations
- start. The default is for these comments to
- start in the same column as those on code.
- OPTION: fB(encdbfR, fB(enncdbfR
- .PP
- Enables (disables) the placement of comment
- delimiters on blank lines. With this option
- enabled, comments look like this:
- .HS
- /*
- * this is a comment
- */
- .HS
- Rather than like this:
- .HS
- /* this is a comment */
- .HS
- This only affects block comments, not comments to the
- right of code. The default is fB(encdbfR.
- OPTION: fB(encefR, fB(enncefR
- .PP
- Enables (disables) forcing *(OQelse*(CQs to cuddle
- up to the immediately preceding *(OQ}*(CQ. The
- default is fB(encefR.
- OPTION: fB(encifInfR
- .PP
- Sets the continuation indent to be fInfR. Continuation lines will be indented
- that far from the beginning of the first line of the
- statement. Parenthesized expressions have
- extra indentation added to indicate the nesting, unless fB(enlpfR
- is in effect. fB(encifR defaults
- to the same value as fB(enifR.
- OPTION: fB(enclifInfR
- .PP
- Causes case labels to be indented fInfR tab stops
- to the right of the containing switch statement. fB(enclifR0.5 causes
- case labels to be
- indented half a tab stop. The default is fB(enclifR0.
- (This is the only option that takes a fractional argument.)
- OPTION: fB(endfIs+2ns0fR
- .PP
- Controls the placement of comments which are
- not to the right of code. Specifying fB(endfR1
- means that such comments are placed one
- indentation level to the left of code. The
- default fB(endfR0 lines up these comments with the
- code. See the section on comment indentation
- below.
- OPTION: fB(endifIs+2ns0fR
- .PP
- Specifies the indentation, in character positions, from a declaration keyword
- to the following identifier. The default is fB(endifR16.
- OPTION: fB(endjfR, fB(enndjfR
- .PP
- fB(endjfR left justifies declarations. fB(enndjfR
- indents declarations the same as code. The
- default is fB(enndjfR.
- OPTION: fB(eneifR, fB(enneifR
- .PP
- Enables (disables) special elsefB(eniffR processing.
- If enabled, ifs following elses will
- have the same indentation as the preceding if
- statement. The default is fB(eneifR.
- OPTION: fB(enfcfR1, fB(ennfcfR1
- .PP
- Enables (disables) the formatting of comments
- that start in column 1. Often, comments
- whose leading *(OQ/*(CQ is in column 1 have been
- carefully hand formatted by the programmer.
- In such cases, fB(ennfcfR1 should be used. The
- default is fB(enfcfR1.
- OPTION: fB(enifIs+1ns0fR
- .PP
- The number of spaces for one indentation
- level. The default is 8.
- OPTION: fB(enipfR, fB(ennipfR
- .PP
- Enables (disables) the indentation of parameter declarations from the
- left margin. The default is fB(enipfR.
- OPTION: fB(enlnfR
- .PP
- Maximum length of an output line. The default is 78.
- OPTION: fB(enlpfR, fB(ennlpfR
- .PP
- Lines up code surrounded by parenthesis in
- continuation lines. If a line has a left
- paren which is not closed on that line, then
- continuation lines will be lined up to start
- at the character position just after the left
- paren.
- OPTION: fB(ennprofR
- .PP
- Causes the profile files, fI.indent.profR in both the current directory
- and the user's home directory to be ignored.
- OPTION: fB(enpcsfR, fB(ennpcsfR
- .PP
- If true (fB(enpcsfR) all procedure calls will have
- a space inserted between the name and the *(OQ(*(CQ.
- The default is fB(ennpcsfR.
- OPTION: fB(enpsfR, fB(ennpsfR
- .PP
- If true (fB(enpsfR) the pointer following operator *(OQ(en>*(CQ will be surrounded by
- spaces on either side. The default is fB(ennpsfR.
- OPTION: fB(enpslfR, fB(ennpslfR
- .PP
- If true (fB(enpslfR) the names of procedures being
- defined are placed in column 1 (en their types,
- if any, will be left on the previous lines.
- The default is fB(enpslfR.
- OPTION: fB(enscfR, fB(ennscfR
- .PP
- Enables (disables) the placement of asterisks
- (*) at the left edge of all comments. The default is fB(enscfR.
- OPTION: fB(ensobfR, fB(ennsobfR
- .PP
- If fB(ensobfR is specified, fIindentfR will swallow
- optional blank lines. You can use this to
- get rid of blank lines after declarations. The default is fB(ennsobfR.
- OPTION: fB(enstfR
- .PP
- Causes fIindentfR to take its input from fIstdinfR, and put its output
- to fIstdoutfR.
- OPTION: fB(enTfItypenamefR
- .PP
- Adds typename to the list of type keywords.
- Names accumulate: fB(enTfR can be specified more
- than once. You need to specify all the
- typenames that appear in your program that
- are defined by #typedefs. Nothing will be
- harmed if you miss a few, but the program
- will not be formatted as nicely as it should.
- This sounds like a painful thing to have to
- do, but it is really a symptom of a problem in
- C: typedef causes a syntactic change in the
- language and fIindentfR cannot find all typedefs.
- OPTION: fB(entrofffR
- .PP
- Causes fIindentfR to format the program for processing by fItrofffR.
- It will produce a fancy listing in much the same spirit as fIvgrindfR.
- If the output file is not specified, the
- default is standard output, rather than formatting in place.
- OPTION: fB(envfR, fB(ennvfR
- .PP
- The fB(envfR flag turns on verbose mode; fB(ennvfR turns it off.
- When in verbose mode, fIindentfR reports when it
- splits one line of input into two or more
- lines of output, and gives some size statistics at completion. The
- default is fB(ennvfR.
- .SS "User Profiles"
- .PP
- You may set up your own profile of defaults to fIindentfR by
- creating a file called fI.indent.profR in either your login
- directory and/or the current directory and including whatever switches
- you like. Switches in fI.indent.profR in the
- current directory override those in your login directory
- (with the exception of fB(enTfR type definitions, which just accumulate).
- If fIindentfR is run and a profile file exists, then
- it is read to set up the program's defaults. The switches
- should be separated by spaces, tabs or newlines. Switches
- on the command line, however, override profile switches.
- .SS "Comments"
- .PP
- fIIndentfR assumes that any comment with a dash
- or 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 that
- its indentation may be adjusted to account for the change in
- indentation of the first line of the comment.
- .PP
- All other comments are treated as straight
- text. Indent fits as many words (separated by blanks, tabs,
- or newlines) on a line as possible. Blank lines break paragraphs.
- .PP
- If a comment is on a line with code it is started in the
- comment column, which is set by the fB(encnfR command line
- parameter. Otherwise, the comment is started at fInfR indentation levels
- less than where code is currently being placed,
- where n is specified by the fB(endnfR command line parameter. If
- the code on a line extends past the comment column, the comment starts
- further to the right, and the right margin may
- be automatically extended in extreme cases.
- .SS "Preprocessor Lines"
- .PP
- In general, fIindentfR leaves preprocessor lines alone. The
- only reformatting that it will do is to straighten up trailing comments.
- It leaves embedded comments alone. Conditional compilation
- (#ifdef...#endif) is recognized and
- fIindentfR attempts to correctly compensate for the syntactic
- peculiarities introduced.
- .SS "C Syntax"
- .PP
- Indent understands a substantial amount about the syntax of
- C, but it has a forgiving parser. It attempts to cope
- with the usual sorts of incomplete and misformed syntax. In
- particular, the use of macros like:
- .HS
- #define forever for(;;)
- .HS
- is handled properly.