📄 indent.tex
字号:
@kindex -cli@var{n}@kindex --case-indentation@var{n}The @samp{-cli} option specifies the number of spaces that case labelsshould be indented to the right of the containing @samp{switch}statement.@kindex -ss@kindex --space-special-semicolon@kindex -nss@kindex --dont-space-special-semicolonIf a semicolon is on the same line as a @code{for} or @code{while}statement, the @samp{-ss} option will cause a space to be placed beforethe semicolon. This emphasizes the semicolon, making it clear that thebody of the @code{for} or @code{while} statement is an empty statement.@code{-nss} disables this feature.@kindex -pcs@kindex --space-after-procedure-calls@kindex -npcs@kindex --no-space-after-function-call-namesThe @samp{-pcs} option causes a space to be placed between the name ofthe procedure being called and the @samp{(} (for example, @w{@code{puts("Hi");}}. The @samp{-npcs} option would give @code{puts("Hi");}).@refill@kindex -cs@kindex --space-after-cast@kindex -ncs@kindex --no-space-after-castsIf the @samp{-cs} option is specified, @code{indent} puts a space aftera cast operator.@kindex -bs@kindex --blank-after-sizeofThe @samp{-bs} option ensures that there is a space between thekeyword @code{sizeof} and its argument. In some versions, this isknown as the @samp{Bill_Shannon} option.@node Declarations, Indentation, Statements, Indent Program@comment node-name, next, previous, up@section Declarations@kindex -di@var{n}@kindex --declaration-indentation@var{n}By default @code{indent} will line up identifiers, in the columnspecified by the @samp{-di} option. For example, @samp{-di16} makesthings look like:@example@groupint foo;char *bar;@end group@end exampleUsing a small value (such as one or two) for the @samp{-di} option canbe used to cause the indentifiers to be placed in the first availableposition, for example@example@groupint foo;char *bar;@end group@end exampleThe value given to the @samp{-di} option will still affect variableswhich are put on separate lines from their types, for example@samp{-di2} will lead to@example@groupint foo;@end group@end example@kindex -bc@kindex --blank-lines-after-commas@kindex -nbc@kindex --no-blank-lines-after-commasIf the @samp{-bc} option is specified, a newline is forced after eachcomma in a declaration. For example,@example@groupint a, b, c;@end group@end example@noindentWith the @samp{-nbc} option this would look like@exampleint a, b, c;@end example@kindex -psl@kindex --procnames-start-lines@kindex -npsl@kindex --dont-break-procedure-type@cindex @code{etags} requires @samp{-psl}The @samp{-psl} option causes the type of a procedure being defined tobe placed on the line before the name of the procedure. This style isrequired for the @code{etags} program to work correctly, as well as someof the @code{c-mode} functions of Emacs.@kindex -T@cindex TypenamesIf you are not using the @samp{-di1} option to place variables beingdeclared immediately after their type, you need to use the @samp{-T}option to tell @code{indent} the name of all the typenames in yourprogram that are defined by @code{typedef}. @samp{-T} can be specifiedmore than once, and all names specified are used. For example, if yourprogram contains@example@grouptypedef unsigned long CODE_ADDR;typedef enum @{red, blue, green@} COLOR;@end group@end example@noindentyou would use the options @samp{-T CODE_ADDR -T COLOR}.@node Indentation, Disabling Formatting, Declarations, Indent Program@comment node-name, next, previous, up@section Indentation@kindex -i@var{n}@kindex --indent-level@var{n}@kindex -ci@var{n}@kindex --continuation-indentation@var{n}@kindex -lp@kindex --continue-at-parentheses@kindex -nlp@kindex --dont-line-up-parenthesesOne issue in the formatting of code is how far each line should beindented from the left margin. When the beginning of a statement suchas @code{if} or @code{for} is encountered, the indentation level isincreased by the value specified by the @samp{-i} option. For example,use @samp{-i8} to specify an eight character indentation for eachlevel. When a statement is broken across two lines, the second line isindented by a number of additional spaces specified by the @samp{-ci}option. @samp{-ci} defaults to 0. However, if the @samp{-lp} option isspecified, and a line has a left parenthesis which is not closed on thatline, then continuation lines will be lined up to start at the characterposition just after the left parenthesis. This processing also appliesto @samp{[} and applies to @samp{@{} when it occurs in initializationlists. For example, a piece of continued code might look like this with@samp{-nlp -ci3} in effect:@example@group p1 = first_procedure (second_procedure (p2, p3), third_procedure (p4, p5));@end group@end example@noindentWith @samp{-lp} in effect the code looks somewhat clearer:@example@group p1 = first_procedure (second_procedure (p2, p3), third_procedure (p4, p5));@end group@end example@kindex -ts@var{n}@kindex --tab-size@var{n}@code{indent} assumes that tabs are placed at regular intervals of bothinput and output character streams. These intervals are by default 8columns wide, but (as of version 1.2) may be changed by the @samp{-ts}option. Tabs are treated as the equivalent number of spaces.@kindex -ip@var{n}@kindex --parameter-indentation@var{n}@kindex -nip@kindex --no-parameter-indentationThe indentation of type declarations in old-style function definitionsis controlled by the @samp{-ip} parameter. This is a numeric parameterspecifying how many spaces to indent type declarations. For example,the default @w{@samp{-ip5}} makes definitions look like this:@example@groupchar *create_world (x, y, scale) int x; int y; float scale;@{ . . .@}@end group@end exampleFor compatibility with other versions of indent, the option @samp{-nip}is provided, which is equivalent to @samp{-ip0}.@kindex -lps@kindex --leave-preprocessor-space@kindex -nlps@kindex --remove-preprocessor-spaceASCII C allows white space to be placed on preprocessor command linesbetween the character @samp{#} and the command name. By default,@code{indent} removes this space, but specifying the @samp{-lps} optiondirects @code{indent} to leave this space unmodified.@node Disabling Formatting, Miscellaneous options, Indentation, Indent Program@comment node-name, next, previous, up@section Disabling FormattingFormatting of C code may be disabled for portions of a program byembedding special @dfn{control comments} in the program. To turn offformatting for a section of a program, place the disabling controlcomment @code{/* *INDENT-OFF* */} on a line by itself just before thatsection. Program text scanned after this control comment is outputprecisely as input with no modifications until the correspondingenabling comment is scanned on a line by itself. The disabling controlcomment is @code{/* *INDENT-ON* */}, and any text following the commenton the line is also output unformatted. Formatting begins again withthe input line following the enabling control comment.More precisely, @code{indent} does not attempt to verify the closingdelimiter (@code{*/}) for these C comments, and any whitespace on theline is totally transparent.These control comments also function in their C++ formats, namely@code{// *INDENT-OFF*} and @code{// *INDENT-ON*}.It should be noted that the internal state of @code{indent} remainsunchanged over the course of the unformatted section. Thus, forexample, turning off formatting in the middle of a function andcontinuing it after the end of the function may lead to bizarreresults. It is therefore wise to be somewhat modular in selecting codeto be left unformatted.As a historical note, some earlier versions of @code{indent} producederror messages beginning with @code{*INDENT**}. These versions of@code{indent} were written to ignore any input text lines which beganwith such error messages. I have removed this incestuous feature from@code{GNU indent}.@node Miscellaneous options, Bugs, Disabling Formatting, Indent Program@comment node-name, next, previous, up@section Miscellaneous options@kindex -versionTo find out what version of @code{indent} you have, use the command@code{indent -version}. This will report the version number of@code{indent}, without doing any of the normal processing.@ignoreThis is intentionally undocumented because1. Although GNU now has groff, it would be better to use TeX.2. The output of indent -troff looks awful, so we have heard. Perhaps it would be reasonable to use this as a starting point to printing a program.If you are printing your program, you may wish to use the @samp{-troff}option to produce output suitable for processing by the @code{troff}program. When the @samp{-troff} option is specified, if the output fileis not specified, the default is standard output, rather than formattingin place.@end ignore@kindex -v@kindex --verbose@kindex -nv@kindex --no-verbosity@comment Would --terse be better? I think not, but perhaps accepting@comment --no-verbose would avoid error messages.The @samp{-v} option can be used to turn on verbose mode. When inverbose mode, @code{indent} reports when it splits one line of inputinto two more more lines of output, and gives some size statistics atcompletion. @node Bugs, Copyright, Miscellaneous options, Indent Program@comment node-name, next, previous, up@section BugsThe "-troff" option is strongly deprecated, and is not supported. Agood thing for someone to do is to rewrite `indent' to generate TeXsource as a hardcopy output option, amoung other things.@node Copyright, , Bugs, Indent Program@comment node-name, next, previous, up@section CopyrightThe following copyright notice applies to the @code{indent} program.The copyright and copying permissions for this manual appear near thebeginning of this document.@displayCopyright (c) 1989, 1992 Free Software FoundationCopyright (c) 1985 Sun Microsystems, Inc.Copyright (c) 1980 The Regents of the University of California.Copyright (c) 1976 Board of Trustees of the University of Illinois.All rights reserved.Redistribution and use in source and binary forms are permittedprovided that the above copyright notice and this paragraph areduplicated in all such forms and that any documentation,advertising materials, and other materials related to suchdistribution and use acknowledge that the software was developedby the University of California, Berkeley, the University of Illinois,Urbana, and Sun Microsystems, Inc. The name of either Universityor Sun Microsystems may not be used to endorse or promote productsderived from this software without specific prior written permission.THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS ORIMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIEDWARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULARPURPOSE.@end display@node Option Summary, Index, Indent Program, Top@appendix Option SummaryHere is a list of all the options for @code{indent}, alphabetized byshort option. It is followed by a cross key alphabetized by long option.@c The cross references are all on lines by themselves because this@c looks better in both printed output and Info. 4 Feb 1992 --rjc@table @samp@item -bad@itemx --blank-lines-after-declarationsForce blank lines after the declarations.@*@xref{Blank lines}.@item -bap@itemx --blank-lines-after-proceduresForce blank lines after procedure bodies.@*@xref{Blank lines}.@item -bbb@itemx --blank-lines-after-block-commentsForce blank lines after block comments.@*@xref{Blank lines}.@item -bc@itemx --blank-lines-after-commasForce newline after comma in declaration.@*@xref{Declarations}.@item -bl@itemx --braces-after-if-linePut braces on line after @code{if}, etc.@*@xref{Statements}.@item -bli@var{n}@item --brace-indent@var{n}Indent braces @var{n} spaces.@*@xref{Statements}.@item -br@itemx --braces-on-if-linePut braces on line with @code{if}, etc. and structure declarations@*@xref{Statements}.@item -c@var{n}@itemx --comment-indentation@var{n}Put comments to the right of code in column @var{n}.@*@xref{Comments}.@item -cd@var{n}@itemx --declaration-comment-column@var{n}Put comments to the right of the declarations in column @var{n}.@*@xref{Comments}.@item -cdb@itemx --comment-delimiters-on-blank-linesPut comment delimiters on blank lines.@*@xref{Comments}.@item -ce
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -