This is an old revision of the document!
Table of Contents
Linux Coding Style
Formatting Tools
indent
The indent program, an excellent GNU utility found on most Linux systems, formats source according to given rules. The default settings are for the GNU coding style, which is not too pretty. To get the utility to follow the Linux kernel style, do
indent -kr -i8 -ts8 -sob -l80 -ss -bs -psl <file>
he default settings are for the GNU coding style, which is not too pretty. To get the utility to follow the Linux kernel style, do
indent -kr -i8 -ts8 -sob -l80 -ss -bs -psl <file>
Code generally has to follow the Linux coding style to be accepted. This style is equivalent to the following settings: -nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 -d0 -di1 -nfc1 -i8 -ip0 -l80 -lp -npcs -nprs -npsl -sai -saf -saw -ncs -nsc -sob -nfca -cp33 -ss -ts8 -il1
| -kr | The C Programming Language The -kr from The the author of The C Programming Language, Brian Kernighan and Dennis Ritchie (Prentice Hall, ISBN# 0-13-11-362-8) |
| -i8 | indentation level to 8 spaces |
| -ts8 | Set tab size to 8 spaces. |
| -sob –swallow-optional-blank-lines | Swallow optional blank lines. |
| -l80 | Set maximum line length for non-comment lines to 80 characters. |
| -ss\\–space-special-semicolon | On one-line for and while statements, force a blank before the semicolon. |
| -bs –Bill-Shannon –blank-before-sizeof | Put a space between sizeof and its argument. |
| -psl –procnames-start-lines | Put the type of a procedure on the line before its name. |
| -nbad | |
| -bap | |
| -nbc | |
| -bbo | |
| -hnl | |
| -br | |
| -brs | |
| -c33 | |
| -cd33 | |
| -ncdb | |
| -ce | |
| -ci4 | |
| -cli0 | |
| -d0 | |
| -di1 | |
| -nfc1 | |
| -i8 | |
| -ip0 | |
| -l80 | |
| -lp | |
| -npcs | |
| -nprs | |
| -npsl | |
| -sai | |
| -saf | |
| -saw | |
| -ncs | |
| -nsc | |
| -sob | |
| -nfca | |
| -cp33 | |
| -ss | |
| -ts8 | |
| -il1 |
