@@ -26,10 +26,12 @@ for FILE
26
26
do
27
27
cat $FILE |
28
28
sed ' s;/\* *---;/*---X_X;g' |
29
+ # workaround for indent bug with 'else' handling
29
30
sed ' s;\([} ]\)else[ ]*\(/\*.*\)$;\1else\
30
- \2;g' | # workaround for indent bug
31
+ \2;g' |
31
32
detab -t4 -qc |
32
- sed ' s;^DATA(.*$;/*&*/;' > /tmp/$$ a # protect backslashes in DATA()
33
+ # protect backslashes in DATA()
34
+ sed ' s;^DATA(.*$;/*&*/;' > /tmp/$$ a
33
35
34
36
# We get the list of typedef's from /src/tools/find_typedef
35
37
indent -bad -bap -bc -bl -d0 -cdb -nce -nfc1 -di12 -i4 -l75 \
792
794
cat /tmp/$$ a |
793
795
sed ' s;^/\*\(DATA(.*\)\*/$;\1;' |
794
796
sed ' s;/\*---X_X;/* ---;g' |
795
- sed ' s;^static[ ][ ]*;static ;g' | # workaround indent bug
797
+ # workaround indent bug
798
+ sed ' s;^static[ ][ ]*;static ;g' |
796
799
sed ' s;^}[ ][ ]*/\*;} /*;' |
797
800
detab -t8 -qc |
798
801
entab -t4 -qc |
799
- sed ' s;^\([A-Za-z_][^ ]*\)[ ][ ]*\*$;\1 *;' | # move trailing * in function return type
800
- awk ' { line3 = $0; /* remove un-needed braces around single statements */
802
+ # move trailing * in function return type
803
+ sed ' s;^\([A-Za-z_][^ ]*\)[ ][ ]*\*$;\1 *;' |
804
+ # remove un-needed braces around single statements
805
+ awk '
806
+ {
807
+ line3 = $0;
801
808
if (skips > 0)
802
809
skips--;
803
810
if (line1 ~ " *{$" &&
823
830
if (skips <= 2)
824
831
print line2;
825
832
}' |
833
+ # Move prototype names to the same line as return type. Useful for ctags.
834
+ # Indent should do this, but it does not. It formats prototypes just
835
+ # like real functions.
836
+ awk ' BEGIN {paren_level = 0}
837
+ {
838
+ if ($0 ~ /^[a-zA-Z_][a-zA-Z_0-9]*[^\(]*$/)
839
+ {
840
+ saved_len = 0;
841
+ saved_lines[++saved_len] = $0;
842
+ if ((getline saved_lines[++saved_len]) == 0)
843
+ print saved_lines[1];
844
+ else
845
+ if (saved_lines[saved_len] !~ /^[a-zA-Z_][a-zA-Z_0-9]*\(/ ||
846
+ saved_lines[saved_len] ~ /^[a-zA-Z_][a-zA-Z_0-9]*\(.*\)$/ ||
847
+ saved_lines[saved_len] ~ /^[a-zA-Z_][a-zA-Z_0-9]*\(.*\);$/)
848
+ {
849
+ print saved_lines[1];
850
+ print saved_lines[2];
851
+ }
852
+ else
853
+ {
854
+ while (1)
855
+ {
856
+ if ((getline saved_lines[++saved_len]) == 0)
857
+ break;
858
+ if (saved_lines[saved_len] ~ /\);?$/ ||
859
+ saved_lines[saved_len] ~ /^[^ ]/ ||
860
+ saved_lines[saved_len] ~ /^$/)
861
+ break;
862
+ }
863
+ for (i=1; i <= saved_len; i++)
864
+ {
865
+ if (i == 1 && saved_lines[saved_len] ~ /\);$/)
866
+ {
867
+ printf "%s", saved_lines[i];
868
+ if (substr(saved_lines[i], length(saved_lines[i]),1) != "*")
869
+ printf " ";
870
+ }
871
+ else print saved_lines[i];
872
+ }
873
+ }
874
+ }
875
+ else print $0;
876
+ }' |
826
877
cat > /tmp/$$ && cat /tmp/$$ > $FILE
827
878
done
828
879
829
- # The 'for' loop makes these backup files useless
830
- # so delete them
880
+ # The 'for' loop makes these backup files useless so delete them
831
881
rm -f * a.BAK
0 commit comments