脚本一:格式化指定目录下的源文件(*.h, *.cpp...)
#!/bin/sh
# 格式化某目录下所有*.h, *.c, *.cpp, *.hh文件, 并将文件换行符转换成Linux下的格式
if [ $# -lt 1 ]; then
echo "Usage: $0 <dir>"
exit 1
else
dir=$1
fi
# format a source file(*.c, *.h, *.cpp, *.hh)
formatSrcfile()
{
dos2unix $1
indent -npro -nip -lp -npsl -npcs -i4 -ts4 -sob -l140 -ci4 -ss -nsaf -nsai -nsaw -bl -bli0 $1
rm -f "$1"~
}
# save file path to file
find $dir -name '*.h' -o -name '*.c' -o -n......
阅读全文