⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 indent.1

📁 早期freebsd实现
💻 1
字号:
.\" Copyright (c) 1980, 1990, 1993.\"	The Regents of the University of California.  All rights reserved..\" Copyright (c) 1976 Board of Trustees of the University of Illinois..\" All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\"    notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\"    notice, this list of conditions and the following disclaimer in the.\"    documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\"    must display the following acknowledgement:.\"	This product includes software developed by the University of.\"	California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\"    may be used to endorse or promote products derived from this software.\"    without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\"	@(#)indent.1	8.1 (Berkeley) 7/1/93.\".Dd July 1, 1993.Dt INDENT 1.Os BSD 4.2.Sh NAME.Nm indent.Nd indent and format C program source.Sh SYNOPSIS.Nm indent.Op Ar input-file Op Ar output-file.Op Fl bad | Fl nbad.Op Fl bap | Fl nbap.Bk -words.Op Fl bbb | Fl nbbb.Ek.Op Fl \&bc | Fl nbc.Op Fl \&bl.Op Fl \&br.Op Fl c Ns Ar n.Op Fl \&cd Ns Ar n.Bk -words.Op Fl cdb | Fl ncdb.Ek.Op Fl \&ce | Fl nce.Op Fl \&ci Ns Ar n.Op Fl cli Ns Ar n.Op Fl d Ns Ar n.Op Fl \&di Ns Ar n.Bk -words.Op Fl fc1 | Fl nfc1.Ek.Op Fl i Ns Ar n.Op Fl \&ip | Fl nip.Op Fl l Ns Ar n.Op Fl \&lc Ns Ar n.Op Fl \&lp | Fl nlp.Op Fl npro.Op Fl pcs | Fl npcs.Op Fl psl | Fl npsl.Op Fl \&sc | Fl nsc.Bk -words.Op Fl sob | Fl nsob.Ek.Op Fl \&st.Op Fl troff.Op Fl v | Fl \&nv.Sh DESCRIPTION.Nm Indentis a.Ar Cprogram formatter.  It reformats the.Ar Cprogram in the.Ar input-fileaccording to the switches.  The switches which can bespecified are described below. They may appear before or after the filenames..Pp.Sy NOTE  :If you only specify an.Ar input-file  ,the formatting isdone `in-place', that is, the formatted file is written back into.Ar input-fileand a backup copy of.Ar input-fileis written in the current directory.  If.Ar input-fileis named.Sq Pa /blah/blah/file ,the backup file is named.Pa file.BAK ..PpIf.Ar output-fileis specified,.Nm indentchecks to make sure it is different from.Ar input-file  ..PpThe options listed below control the formatting style imposed by.Nm indent  ..Bl -tag -width Op.It Fl bad , nbadIf.Fl badis specified, a blank line is forced after every block ofdeclarations.  Default:.Fl nbad  ..It Fl bap , nbapIf.Fl bapis specified, a blank line is forced after every procedure body.  Default:.Fl nbap ..It Fl bbb , nbbbIf.Fl bbbis specified, a blank line is forced before every block comment.  Default:.Fl nbbb ..It Fl \&bc , nbcIf.Fl \&bcis specified, then a newline is forced after each comma in a declaration..Fl nbcturns off this option.  The default is.Fl \&bc  ..It Fl \&br , \&blSpecifying.Fl \&bllines up compound statements like this:.ne 4.Bd -literal -offset indentif (...){  code}.Ed.PpSpecifying.Fl \&br(the default) makes them look like this:.ne 3.Bd -literal -offset indentif (...) {  code}.Ed.Pp.It Fl c nThe column in which comments on code start.  The default is 33..It Fl cd nThe column in which comments on declarations start.  The defaultis for these comments to start in the same column as those on code..It Fl cdb , ncdbEnables (disables) the placement of comment delimiters on blank lines.  Withthis option enabled, comments look like this:.Bd -literal -offset indent.ne 3	/*	* this is a comment	*/.Ed.PpRather than like this:.Bd -literal -offset indent	/* this is a comment */.Ed.PpThis only affects block comments, not comments to the right ofcode.  The default is.Fl cdb  ..It Fl ce , nceEnables (disables) forcing `else's to cuddle up to the immediately preceding`}'.  The default is.Fl \&ce  ..It Fl \&ci Ns Ar n Sets the continuation indent to be.Ar n  .Continuationlines will be indented that far from the beginning of the first line of thestatement.  Parenthesized expressions have extra indentation added toindicate the nesting, unless.Fl \&lpis in effect..Fl \&cidefaults to the same value as.Fl i  ..It Fl cli Ns Ar n Causes case labels to be indented.Ar ntab stops to the right of the containing.Ic switchstatement..Fl cli0 .5causes case labels to be indented half a tab stop.  Thedefault is.Fl cli0  ..It Fl d Ns Ar n Controls the placement of comments which are not to theright of code.  The default.Fl \&d\&1means that such comments are placed one indentation level to theleft of code.  Specifying.Fl \&d\&0lines up these comments with the code.  See the section on commentindentation below..It Fl \&di Ns Ar n Specifies the indentation, in character positions, from a declaration keywordto the following identifier.  The default is.Fl di16  ..It Fl dj , ndj.Fl \&djleft justifies declarations..Fl ndjindents declarations the same as code.  The default is.Fl ndj  ..It Fl \&ei , neiEnables (disables) special.Ic else-ifprocessing.  If it's enabled, an.Ic iffollowing an.Ic elsewill have the same indentation as the preceding.Ic \&ifstatement..It Fl fc1 , nfc1Enables (disables) the formatting of comments that start in column 1.Often, comments whose leading `/' is in column 1 have been carefullyhand formatted by the programmer.  In such cases,.Fl nfc1should beused.  The default is.Fl fc1  ..It Fl i Ns Ar n The number of spaces for one indentation level.  The default is 4..It Fl \&ip , nipEnables (disables) the indentation of parameter declarations from the leftmargin.  The default is.Fl \&ip  ..It Fl l Ns Ar n Maximum length of an output line.  The default is 75..It Fl \&lp , nlpLines up code surrounded by parenthesis in continuation lines.  If a linehas a left paren which is not closed on that line, then continuation lineswill be lined up to start at the character position just after the leftparen.  For example, here is how a piece of continued code looks with.Fl nlpin effect:.ne 2.Bd -literal -offset indentp1 = first_procedure(second_procedure(p2, p3),\ \ third_procedure(p4,p5));.Ed.Pp.ne 5With.Fl lpin effect (the default) the code looks somewhat clearer:.Bd -literal -offset indentp1\ =\ first_procedure(second_procedure(p2,\ p3),\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ third_procedure(p4,p5));.Ed.Pp.ne 5Inserting two more newlines we get:.Bd -literal -offset indentp1\ =\ first_procedure(second_procedure(p2,\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ p3),\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ third_procedure(p4\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ p5));.Ed.It Fl nproCauses the profile files,.Sq Pa ./.indent.proand.Sq Pa ~/.indent.pro ,to be ignored..It Fl pcs , npcsIf true.Pq Fl pcsall procedure calls will have a space inserted betweenthe name and the `('.  The default is.Fl npcs  ..It Fl psl , npslIf true.Pq Fl pslthe names of procedures being defined are placed incolumn 1 \- their types, if any, will be left on the previous lines.  Thedefault is.Fl psl  ..It Fl \&sc , nscEnables (disables) the placement of asterisks (`*'s) at the left edge of allcomments..It Fl sob , nsobIf.Fl sobis specified, indent will swallow optional blank lines.  You can use this toget rid of blank lines after declarations.  Default:.Fl nsob  ..It Fl \&stCauses.Nm indentto take its input from stdin, and put its output to stdout..It Fl T Ns Ar typename Adds.Ar typenameto the list of type keywords.  Names accumulate:.Fl Tcan be specified more than once.  You need to specify all the typenames thatappear in your program that are defined by.Ic typedef\- nothing will beharmed if you miss a few, but the program won't be formatted as nicely asit should.  This sounds like a painful thing to have to do, but it's reallya symptom of a problem in C:.Ic typedefcauses a syntactic change in thelanguage and.Nm indentcan't find allinstances of.Ic typedef ..It Fl troffCauses.Nm indentto format the program for processing by.Xr troff 1 .It will produce a fancylisting in much the same spirit as.Xr vgrind 1 .If the output file is not specified, the default is standard output,rather than formatting in place..It Fl v , \&nv.Fl vturns on `verbose' mode;.Fl \&nvturns it off.  When in verbose mode,.Nm indentreports when it splits one line of input into two or more lines of output,and gives some size statistics at completion. The default is.Fl \&nv  ..El.PpYou may set up your own `profile' of defaults to.Nm indentby creating a file called.Pa .indent.proin your login directory and/or the current directory and includingwhatever switches you like.  A `.indent.pro' in the current directory takesprecedence over the one in your login directory.  If.Nm indentis run and a profile file exists, then it is read to set up the program'sdefaults.  Switches on the command line, though, always override profileswitches.  The switches should be separated by spaces, tabs or newlines..Pp.Ss Comments.Sq Em Box.Em comments ..Nm Indentassumes that any comment with a dash or star immediately after the start ofcomment (that is, `/*\-' or `/**') is a comment surrounded by a box of stars.Each line of such a comment is left unchanged, except that its indentationmay be adjusted to account for the change in indentation of the first lineof the comment..Pp.Em Straight text .All other comments are treated as straight text..Nm Indentfits as many words (separated by blanks, tabs, or newlines) on aline as possible.  Blank lines break paragraphs..Pp.Ss Comment indentationIf a comment is on a line with code it is started in the `comment column',which is set by the.Fl c Ns Ns Ar n command line parameter.  Otherwise, the comment is started at.Ar nindentation levels less than where code is currently being placed, where.Ar nis specified by the.Fl d Ns Ns Ar n command line parameter.  If the code on a line extends past the commentcolumn, the comment starts further to the right, and the right margin may beautomatically extended in extreme cases..Pp.Ss Preprocessor linesIn general,.Nm indentleaves preprocessor lines alone.  The onlyreformatting that it will do is to straighten up trailing comments.  Itleaves embedded comments alone.  Conditional compilation.Pq Ic #ifdef...#endifis recognized and.Nm indentattempts to correctlycompensate for the syntactic peculiarities introduced..Pp.Ss C syntax.Nm Indentunderstands a substantial amount about the syntax of C, but ithas a `forgiving' parser.  It attempts to cope with the usual sorts ofincomplete and misformed syntax.  In particular, the use of macros like:.Pp.Dl #define forever for(;;).Ppis handled properly..Sh ENVIRONMENT.Nm Indentuses the.Ev HOMEenvironment variable..Sh FILES.Bl -tag -width "./.indent.pro" -compact.It Pa ./.indent.proprofile file.It Pa ~/.indent.proprofile file.El.Sh HISTORYThe.Nm indentcommand appeared in.Bx 4.2 ..Sh BUGS.Nm Indenthas even more switches than.Xr ls 1 ..Pp.ne 5A common mistake that often causes grief is typing:.Pp.Dl indent *.c.Ppto the shell in an attempt to indent all the.Nm Cprograms in a directory.This is probably a bug, not a feature.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -