|
发表于 2004-8-31 16:34:20
|
显示全部楼层
In Linux, indenting the source files could be automaticaly by using this command:
indent -bli0 -nut -i4 -fc1 -sc test.c test2.c ....
This is a reference script. The script could indent the C cource files of current
directory (such as "*.c", "*.h", "*.cpp", "*.hpp", "*.C" etc.) recurisvly.
Please rename the script to indentall.sh and copy this command to your working directory.
Usage:
Enter the directory which contain the source files and type the command:
indentall.sh <enter>
----------------------------------------------->8
#!/bin/sh
#
# filename: indentall.sh
#
# indent the C source files of one directory recursivly.
# the script support dir/file name that contain spaces(" ")
#
INDENT="indent -bli0 -nut -i4 -fc1 -sc"
RM="rm"
if [ -z "$1" ]; then
find . -name "*.[CHch]" | $0 -p
find . -name "*.[ch]pp" | $0 -p
else
read fname
until [ -z "$fname" ]; do
if [ -d "$fname" ] ; then
echo "Enter directory: '$fname'"
elif [ -L "$fname" ] ; then
echo "Skip linker: '$fname'"
else
echo "Parse file: $fname"
$INDENT "$fname"
$RM "$fname""~"
fi
read fname
done
fi
----------------------------------------------->8 |
|