home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 6
/
FreshFish_September1994.bin
/
gnu
/
info
/
indent.info
(
.txt
)
< prev
next >
Wrap
GNU Info File
|
1994-09-02
|
43KB
|
996 lines
This is Info file indent.info, produced by Makeinfo-1.54 from the input
file ./indent.texinfo.
Copyright (C) 1989, 1992, 1993, 1994 Free Software Foundation, Inc.
This is Edition 1.3, January, 1994, of `The `indent' Manual', for
Indent Version 1.9
Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
preserved on all copies.
File: indent.info, Node: Top, Next: Indent Program, Prev: (dir), Up: (dir)
`indent': Indent and Format C Program Source
*********************************************
The `indent' program changes the appearance of a C program by
inserting or deleting whitespace.
This is Edition 1.3, January 1994, of `The `indent' Manual', for
Indent Version 1.9
* Menu:
* Indent Program:: The `indent' Program
* Option Summary:: Option Summary
* Index:: Index
File: indent.info, Node: Indent Program, Next: Option Summary, Prev: Top, Up: Top
The `indent' Program
********************
The `indent' program can be used to make code easier to read. It
can also convert from one style of writing C to another.
`indent' understands a substantial amount about the syntax of C, but
it also attempts to cope with incomplete and misformed syntax.
In version 1.2 and more recent versions, the GNU style of indenting
is the default.
* Menu:
* Invoking indent:: Invoking `indent'
* Backup files:: Backup Files
* Common styles:: Common styles
* Blank lines:: Blank lines
* Comments:: Comments
* Statements:: Statements
* Declarations:: Declarations
* Indentation:: Indentation
* Disabling Formatting:: Disabling Formatting
* Miscellaneous options:: Miscellaneous options
* Bugs:: Bugs
* Copyright:: Copyright
File: indent.info, Node: Invoking indent, Next: Backup files, Up: Indent Program
Invoking `indent'
=================
As of version 1.3, the format of the `indent' command is:
indent [OPTIONS] [INPUT-FILES]
indent [OPTIONS] [SINGLE-INPUT-FILE] [-o OUTPUT-FILE]
This format is different from earlier versions and other versions of
`indent'.
In the first form, one or more input files are specified. `indent'
makes a backup copy of each file, and the original file is replaced with
its indented version. *Note Backup files::, for an explanation of how
backups are made.
In the second form, only one input file is specified. In this case,
or when the standard input is used, you may specify an output file after
the `-o' option.
To cause `indent' to write to standard output, use the `-st' option.
This is only allowed when there is only one input file, or when the
standard input is used.
If no input files are named, the standard input is read for input.
Also, if a filename named `-' is specified, then the standard input is
read.
As an example, each of the following commands will input the program
`slithy_toves.c' and write its indented text to `slithy_toves.out':
indent slithy_toves.c -o slithy_toves.out
indent -st slithy_toves.c > slithy_toves.out
cat slithy_toves.c | indent -o slithy_toves.out
Most other options to `indent' control how programs are formatted.
As of version 1.2, `indent' also recognizes a long name for each option
name. Long options are prefixed by either `--' or `+'.(1) In most of
this document, the traditional, short names are used for the sake of
brevity. *Note Option Summary::, for a list of options, including both
long and short names.
Here is another example:
indent -br test/metabolism.c -l85
This will indent the program `test/metabolism.c' using the `-br' and
`-l85' options, write the output back to `test/metabolism.c', and write
the original contents of `test/metabolism.c' to a backup file in the
directory `test'.
Equivalent invocations using long option names for this example would
indent --braces-on-if-line --line-length185 test/metabolism.c
indent +braces-on-if-line +line-length185 test/metabolism.c
If you find that you often use `indent' with the same options, you
may put those options into a file called `.indent.pro'. `indent' will
first look for `.indent.pro' in the current directory and use that if
found. Otherwise, `indent' will search your home directory for
`.indent.pro' and use that file if it is found. This behaviour is
different from that of other versions of `indent', which load both
files if they both exist.
Command line switches are handled *after* processing `.indent.pro'.
Options specified later override arguments specified earlier, with one
exception: Explicitly specified options always override background
options (*note Common styles::.). You can prevent `indent' from
reading an `.indent.pro' file by specifying the `-npro' option.
---------- Footnotes ----------
(1) `+' is being superseded by `--' to maintain consistency with
the POSIX standard.
File: indent.info, Node: Backup files, Next: Common styles, Prev: Invoking indent, Up: Indent Program
Backup Files
============
As of version 1.3, GNU `indent' makes GNU-style backup files, the
same way GNU Emacs does. This means that either "simple" or "numbered"
backup filenames may be made.
Simple backup file names are generated by appending a suffix to the
original file name. The default for the this suffix is the
one-character string `~' (tilde). Thus, the backup file for `python.c'
would be `python.c~'.
Instead of the default, you may specify any string as a suffix by
setting the environment variable `SIMPLE_BACKUP_SUFFIX' to your
preferred suffix.
Numbered backup versions of a file `momewraths' look like
`momewraths.c.~23~', where 23 is the version of this particular backup.
When making a numbered backup of the file `src/momewrath.c', the
backup file will be named `src/momewrath.c.~V~', where V is one greater
than the highest version currently existing in the directory `src'.
The type of backup file made is controlled by the value of the
environment variable `VERSION_CONTROL'. If it is the string `simple',
then only simple backups will be made. If its value is the string
`numbered', then numbered backups will be made. If its value is
`numbered-existing', then numbered backups will be made if there
*already exist* numbered backups for the file being indented;
otherwise, a simple backup is made. If `VERSION_CONTROL' is not set,
then `indent' assumes the behaviour of `numbered-existing'.
Other versions of `indent' use the suffix `.BAK' in naming backup
files. This behaviour can be emulated by setting
`SIMPLE_BACKUP_SUFFIX' to `.BAK'.
Note also that other versions of `indent' make backups in the
current directory, rather than in the directory of the source file as
GNU `indent' now does.
File: indent.info, Node: Common styles, Next: Blank lines, Prev: Backup files, Up: Indent Program
Common styles
=============
There are several common styles of C code, including the GNU style,
the Kernighan & Ritchie style, and the original Berkeley style. A
style may be selected with a single "background" option, which
specifies a set of values for all other options. However, explicitly
specified options always override options implied by a background
option.
As of version 1.2, the default style of GNU `indent' is the GNU
style. Thus, it is no longer neccessary to specify the option `-gnu'
to obtain this format, although doing so will not cause an error.
Option settings which correspond to the GNU style are:
-nbad -bap -nbc -bl -bli2 -c33 -cd33 -ncdb -nce -cli0
-cp1 -di2 -nfc1 -nfca -i2 -ip5 -lp -pcs -psl -cs
-nsc -nsob -nss -ts8 -d0 -ci0 -l78
The GNU coding style is that preferred by the GNU project. It is the
style that the GNU Emacs C mode encourages and which is used in the C
portions of GNU Emacs. (People interested in writing programs for
Project GNU should get a copy of `The GNU Coding Standards', which also
covers semantic and portability issues such as memory usage, the size
of