Skip to content

Commit

Permalink
Divergence: remove unwanted spaces for typedef
Browse files Browse the repository at this point in the history
This patch removes unwanted spaces for typedef. This solution doesn't cover
function types.

Note that the linuxize result of this commit is very giant and should have
many conflicts against the current Linux upstream. Thus it is required to
modify the linuxize result of this commit and the commits around it
manually in order to have them merged to the Linux upstream. Since this is
very costy, we should do this only once, and if we can't ensure to do this
only once, we need to revert the Linux code to the wrong indentation result
before merging the linuxize result of this commit. Lv Zheng.

Signed-off-by: Lv Zheng <lv.zheng@intel.com>
  • Loading branch information
Lv Zheng committed Mar 29, 2016
1 parent 058fb3c commit b2294ca
Showing 1 changed file with 56 additions and 15 deletions.
71 changes: 56 additions & 15 deletions generate/linux/libacpica.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ fi
CURDIR=`pwd`
TOOLDIR=$SCRIPT/bin
ACPISRC=$TOOLDIR/acpisrc
ACPI_TYPES=

linux_dirs()
{
Expand Down Expand Up @@ -215,23 +216,61 @@ make_acpisrc()
make_tool $1 acpisrc
}

find_typedefs()
{
cat $1 | awk '
{
if (match($0, /^typedef[_a-zA-Z0-9\* \t]+;/)) {
s1=substr($0, RSTART, RLENGTH)
if (match(s1, /^typedef[ \t]+/)) {
s2=substr(s1, RLENGTH+1)
if (match(s2, /(signed|unsigned)[ \t]+/)) {
s3=substr(s2, RLENGTH+1)
} else {
s3=s2
}
if (match(s3, /[_a-zA-Z0-9]+[ \t]+/)) {
s4=substr(s3, RLENGTH+1)
if (match(s4, /\*[ \t]*/)) {
s5=substr(s4, RLENGTH+1)
} else {
s5=s4
}
if (match(s5, /[_a-zA-Z0-9]+/)) {
def=substr(s5, RSTART, RLENGTH)
print def
}
}
}
}
}
'
}

find_all_typedefs()
{
local f files

files=`find . -name "*.h"`
for f in $files; do
find_typedefs $f
done
}

lindent_find_typedefs()
{
ACPI_TYPES=`find_all_typedefs | sort | uniq`
}

lindent_single()
{
local acpi_types t indent_flags

acpi_types="\
u8 \
u16 \
u32 \
u64 \
acpi_integer \
acpi_predefined_data \
acpi_operand_object \
acpi_event_status \
"
local t indent_flags

indent_flags="-npro -kr -i8 -ts8 -sob -l80 -ss -ncs -il0"
for t in $acpi_types; do
for t in $ACPI_TYPES; do
if [ "x$2" = "xtrue" ]; then
echo " Adding type $t"
fi
indent_flags="$indent_flags -T $t"
done

Expand All @@ -241,13 +280,15 @@ lindent_single()

lindent()
{
local files f
local files f verbose=true

(
cd $1
lindent_find_typedefs
files=`find . -name "*.[ch]" | cut -c3-`
for f in $files; do
lindent_single $f
lindent_single $f $verbose
verbose=false
done
find . -name "*~" | xargs rm -f
)
Expand Down

0 comments on commit b2294ca

Please sign in to comment.