File: code-format.sh

package info (click to toggle)
shadowsocks-libev 3.3.5%2Bds-16
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,496 kB
  • sloc: ansic: 14,124; sh: 1,338; makefile: 197; python: 111
file content (27 lines) | stat: -rwxr-xr-x 628 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env bash

root=$(pwd)
source="$root"/src

function format() {
  filelist=$(ls "$1")
  pushd "$1"
  for file in $filelist; do
    if test -d "$file"; then
      echo "format directory $file"
      format "$file"
    else
      if ([ "${file%%.*}" != "base64" ] &&
        [ "${file%%.*}" != "json" ] &&
        [ "${file%%.*}" != "uthash" ]) &&
        ([ "${file##*.}" = "h" ] || [ "${file##*.}" = "c" ]); then
        echo "format file $file"
        uncrustify -c "$root"/.uncrustify.cfg -l C --replace --no-backup "$file"
        rm ./*.uncrustify >/dev/null 2>&1
      fi
    fi
  done
  popd
}

format "$source"