User Tools

Site Tools


mywiki:linux:linux_soding_style

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
mywiki:linux:linux_soding_style [2014/09/28 07:20] shaoguohmywiki:linux:linux_soding_style [2022/04/02 17:29] (current) – external edit 127.0.0.1
Line 12: Line 12:
  
 To get the utility to follow the Linux kernel style, the simple usage is :  To get the utility to follow the Linux kernel style, the simple usage is : 
-<nowiki> indent -kr -i8 -ts8 -sob -l80 -ss -bs -psl <file> </nowiki>+    indent -kr -i8 -ts8 -sob -l80 -ss -bs -psl < file > 
  
-For detailsbelow setting is used+Note: -l is new as of version 2.1 however and not very intelligent or flexible yet.  
 + 
 +Maybe need to add "-**-ignore-newlines**" to disable -l80 
 + 
 + 
 + 
 +The **K**ernighan & **R**itchie style corresponds to the following set of options: 
 +<file> 
 +-nbad -bap -bbo -nbc -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 
 +-cp33 -cs -d0 -di1 -nfc1 -nfca -hnl -i4 -ip0 -l75 -lp -npcs 
 +-nprs -npsl -saf -sai -saw -nsc -nsob -nss 
 +</file> 
 + 
 +This Linux style (-linux--linux-style ) is equivalent to the following settings
 <file> <file>
 -nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4  -nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4 
Line 20: Line 33:
 -saf -saw -ncs -nsc -sob -nfca -cp33 -ss -ts8 -il1 -saf -saw -ncs -nsc -sob -nfca -cp33 -ss -ts8 -il1
 </file> </file>
 +
 +
  
 | -kr | The C Programming Language\\  The -kr from The the author of **The C Programming Language**, Brian **K**ernighan and Dennis **R**itchie\\ (Prentice Hall, ISBN# 0-13-11-362-8)  | | -kr | The C Programming Language\\  The -kr from The the author of **The C Programming Language**, Brian **K**ernighan and Dennis **R**itchie\\ (Prentice Hall, ISBN# 0-13-11-362-8)  |
Line 64: Line 79:
 | -il1 |  | | -il1 |  |
  
 +==== Options' Cross Key ====
 +
 +Here is a list of options alphabetized by long option, to help you find the corresponding short option.
 +<file>
 +--blank-lines-after-commas                      -bc             
 +--blank-lines-after-declarations                -bad            
 +--blank-lines-after-procedures                  -bap            
 +--blank-lines-before-block-comments             -bbb            
 +--braces-after-if-line                          -bl             
 +--braces-after-func-def-line                    -blf
 +--brace-indent                                  -bli
 +--braces-after-struct-decl-line                 -bls
 +--braces-on-if-line                             -br             
 +--braces-on-func-def-line                       -brf
 +--braces-on-struct-decl-line                    -brs
 +--break-after-boolean-operator                  -nbbo
 +--break-before-boolean-operator                 -bbo
 +--break-function-decl-args                      -bfda
 +--break-function-decl-args-end                  -bfde
 +--case-indentation                              -clin     
 +--case-brace-indentation                        -cbin
 +--comment-delimiters-on-blank-lines             -cdb            
 +--comment-indentation                           -cn       
 +--continuation-indentation                      -cin      
 +--continue-at-parentheses                       -lp             
 +--cuddle-do-while                               -cdw
 +--cuddle-else                                   -ce             
 +--declaration-comment-column                    -cdn      
 +--declaration-indentation                       -din      
 +--dont-break-function-decl-args                 -nbfda
 +--dont-break-function-decl-args-end             -nbfde
 +--dont-break-procedure-type                     -npsl           
 +--dont-cuddle-do-while                          -ncdw
 +--dont-cuddle-else                              -nce            
 +--dont-format-comments                          -nfca           
 +--dont-format-first-column-comments             -nfc1           
 +--dont-line-up-parentheses                      -nlp            
 +--dont-left-justify-declarations                -ndj  
 +--dont-space-special-semicolon                  -nss
 +--dont-star-comments                            -nsc            
 +--else-endif-column                             -cpn
 +--format-all-comments                           -fca            
 +--format-first-column-comments                  -fc1            
 +--gnu-style                                     -gnu            
 +--honour-newlines                               -hnl
 +--ignore-newlines                               -nhnl
 +--ignore-profile                                -npro           
 +--indent-label                                  -iln       
 +--indent-level                                  -in       
 +--k-and-r-style                                 -kr             
 +--leave-optional-blank-lines                    -nsob           
 +--leave-preprocessor-space                      -lps
 +--left-justify-declarations                     -dj 
 +--line-comments-indentation                     -dn       
 +--line-length                                   -ln       
 +--linux-style                                   -linux             
 +--no-blank-lines-after-commas                   -nbc            
 +--no-blank-lines-after-declarations             -nbad           
 +--no-blank-lines-after-procedures               -nbap           
 +--no-blank-lines-before-block-comments          -nbbb           
 +--no-comment-delimiters-on-blank-lines          -ncdb           
 +--no-space-after-casts                          -ncs            
 +--no-parameter-indentation                      -nip            
 +--no-space-after-for -nsaf
 +--no-space-after-function-call-names            -npcs           
 +--no-space-after-if -nsai
 +--no-space-after-parentheses                    -nprs
 +--no-space-after-while -nsaw
 +--no-tabs                                       -nut
 +--no-verbosity                                  -nv             
 +--original                                      -orig
 +--parameter-indentation                         -ipn      
 +--paren-indentation                             -pin
 +--preserve-mtime -pmt
 +--preprocessor-indentation                      -ppin
 +--procnames-start-lines                         -psl            
 +--space-after-cast                              -cs             
 +--space-after-for -saf
 +--space-after-if -sai
 +--space-after-parentheses                       -prs
 +--space-after-procedure-calls                   -pcs            
 +--space-after-while -saw
 +--space-special-semicolon                       -ss             
 +--standard-output                               -st             
 +--start-left-side-of-comments                   -sc             
 +--struct-brace-indentation                      -sbin
 +--swallow-optional-blank-lines                  -sob            
 +--tab-size                                      -tsn      
 +--use-tabs                                      -ut
 +--verbose                                       -v              
 +</file>
 +
 +
 +===== Astyle =====
 +astyle special usage based on V2.0.4 http://astyle.sourceforge.net/astyle.html
 +
 +Example: 
 +astyle --options=none --align-pointer=name --pad=oper --unpad-paren --pad-paren-out --trim-trailing-whitespace
 +
 +--options=none   
 +    Disable the default options file. Only the command-line  parameters will be used.
 +  
 +-p, --pad=oper   
 +    Insert space padding around operators  only. for example: i-j becomes i - j
 +
 +-U, --unpad-paren
 +    Remove space padding around parenthesis on the inside  and  out‐
 +    side. Can be used in combination with the paren padding options.
 +    Only padding that has not been requested by other  options  will
 +    be removed.
 +
 +-d, --pad-paren-out  
 +      Insert space paddings around parenthesies on the  outside  only.
 +      This can be used with unpad=paren to remove unwanted spaces.
 +      
 +      With -U -d two options, it will be like if (k > 0), not if( k > 0 )
 +
 +-k3, --align-pointer=name
 +      Attach a pointer or reference operator (*, &, or ^) to the variable name (right).
 +      for example: **char* p** becomes **char *p**
 +       
 +===== Perl/Bash =====
 +Use perl to remove trailing whitespace in a string:
 +    $str =~ s/\s+$//;
 +Take 1 or more white spaces (\s+) till the end of the string ($), and replace them with an empty string.     
mywiki/linux/linux_soding_style.1411860058.txt.gz · Last modified: (external edit)