Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.54 KB | None | 0 0
  1. function makepatch()
  2. {
  3.     # remember current directory
  4.     cwd=$(pwd);
  5.  
  6.     # check how many lines of unified context should be created
  7.     if [ $# -eq 0 ]; then
  8.         return;
  9.     elif [ $# -eq 1 ]; then
  10.         lines=5;
  11.     else
  12.         lines=$2;
  13.     fi
  14.  
  15.     # create patch
  16.     cd0adsvn;
  17.     svn diff --diff-cmd diff -x "-p -U$lines" . > /media/tmpfs2/patch
  18.  
  19.     # restore current directory
  20.     cd "$cwd";
  21. }
  22.  
  23. function checkPatch()
  24. {
  25.     # whitespace
  26.     grep -n -P '^\+.*[[:blank:]]$' $1       # trailing whitespace
  27.     grep -n -P '^\+.*\ \t' $1           # mixed whitespace
  28.     # TODO: prohibit spaces before the first letter
  29.     # TODO: warn if too many tabs are found
  30.  
  31.     # space in loops
  32.     grep -n -P '^\+.*for\(' $1          # for(
  33.     grep -n -P '^\+.*if\(' $1           # if(
  34.     grep -n -P '^\+.*switch\(' $1           # switch(
  35.     grep -n -P '^\+.*while\(' $1            # while(
  36.     grep -n '\ No newline at end of file' $1    # file should end with newline
  37.  
  38.     # check that objects have spaces like { this }
  39.     grep -n -P '^\+.*\{"' $1            # {"
  40.     grep -n -P '^\+.*\)\}' $1           # )}
  41.     grep -n -P '^\+.*\}\}' $1           # }}
  42.  
  43.     # Use unary plus instead of parseInt
  44.     # both evaluate to NaN in case
  45.     grep -n -P '^\+.*ParseInt\(' $1         # ParseInt
  46.  
  47.     # Use for ... of and for ... in
  48.     # instead of for each
  49.     grep -n -P '^\+.*for each' $1           # for each
  50.  
  51.     # Use fat arrow functions instead of inline functions
  52.     grep -n -P '^\+.*function.*\{' $1
  53.  
  54.     ####################################
  55.     # C++
  56.  
  57.     # CStr and CStrW should be used
  58.     # instead of std::string and std::wstring
  59.     grep -n -P '^\+.*std::string' $1        # CStr
  60.     grep -n -P '^\+.*std::wstring' $1       # CStrW
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement