]>
git.saurik.com Git - wxWidgets.git/blob - src/png/scripts/chkfmt
   3 # Check the format of the source files in the current directory - checks for a 
   4 # line length of 80 characters max and no tab characters. 
   6 # Optionally arguments are files or directories to check. 
   8 # -v: output the long lines (makes fixing them easier) 
   9 # -e: spawn an editor for each file that needs a change ($EDITOR must be 
  10 #     defined).  When using -e the script MUST be run from an interactive 
  25       # Copy the standard streams for the editor 
  28       echo "chkfmt -e: EDITOR must be defined" >&2 
  33 # Function to edit a single file - if the file isn't changed ask the user 
  34 # whether or not to continue.  This stuff only works if the script is run from 
  35 # the command line (otherwise, don't specify -e or you will be sorry). 
  37    cp "$file" "$file".orig
 
  38    "$EDITOR" "$file" 0>&3 1>&4 2>&5 3>&- 4>&- 5>&- || exit 1 
  39    if cmp -s "$file".orig 
"$file" 
  42       echo -n "$file: file not changed, type anything to continue: " >&5 
  44       test -n "$ans" || return 1 
  49 # In beta versions the version string which appears in files can be a little 
  50 # long and cause spuriously overlong lines.  To avoid this subtitute the version 
  51 # string with a 'standard' version a.b.cc before checking for long lines. 
  55    's/^#define PNG_LIBPNG_VER_STRING .\([0-9]\.[0-9]\.[0-9][0-9a-z]*\).$/\1/p' \ 
  57    echo "chkfmt: checking version $vers" 
  61    echo "chkfmt: png.h not found, ignoring version number" >&2 
  64 test -n "$1" || set -- .
 
  65 find "$@" \
( -type d \
( -name '.git' -o -name '.libs' -o -name 'projects' \
) \
 
  66    -prune \
) -o \
( -type f \
 
  67    ! -name '*.[oa]' ! -name '*.l[oa]' !  -name '*.png' ! -name '*.out' \
 
  68    ! -name '*.jpg' ! -name '*.patch' ! -name '*.obj' ! -name '*.exe' \
 
  69    ! -name '*.com' ! -name '*.tar.*' ! -name '*.zip' ! -name '*.ico' \
 
  70    ! -name '*.res' ! -name '*.rc' ! -name '*.mms' ! -name '*.rej' \
 
  71    ! -name '*.dsp' ! -name '*.orig' ! -name '*.dfn' ! -name '*.swp' \
 
  72    ! -name '~*' ! -name '*.3' \
 
  73    ! -name 'missing' ! -name 'mkinstalldirs' ! -name 'depcomp' \
 
  74    ! -name 'aclocal.m4' ! -name 'install-sh' ! -name 'Makefile.in' \
 
  75    ! -name 'ltmain.sh' ! -name 'config*' -print \
) | { 
  80       *.mak
|*[Mm
]akefile.
*|*[Mm
]akefile
) 
  81          # Makefiles require tabs, dependency lines can be this long. 
  85          # Includes literal tabs 
  87          # The following is arbitrary 
  97       # Note that vers can only contain 0-9, . and a-z 
 100          sed -e "s/$vers/a.b.cc/g" "$file" >"$file".$$
 
 102          cp "$file" "$file".$$
 
 104       splt
="`fold -$line_length "$file".$$ | diff -c "$file".$$ -`" 
 109          echo "$file: lines too long" 
 111          if test -n "$EDITOR" -a -n "$edit" 
 113             doed 
"$file" || exit 1 
 114          elif test -n "$verbose" 
 119       if test -n "$check_tabs" 
 121          tab
="`tr -c -d '\t' <"$file"`" 
 124             echo "$file: file contains tab characters" 
 126             if test -n "$EDITOR" -a -n "$edit" 
 128                doed 
"$file" || exit 1 
 129             elif test -n "$verbose"