blob: 52a7252930babf0f2e710a002b24582288e0fb5c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# drop if don't start with typedef
/^\s*typedef/ ! b
# read one line typedef (struct)? (word*)? (*)? word;
s/^\s*typedef\s+(struct\s+)?((\w+\**\s+)*)(\w+)\s*;.*$/typedef \1 \2 \4;/
t finish
# read multi line
s/^\s*typedef\s+(struct.*[^;].*)/typedef \1/
# leave if substitution fails, or copy pattern to hold space
T; h
:loop; n
# read till } is reached
/^\s*\}/ ! b loop
# take care of the last } word;
s/^\s*\}\s*(\w+)\s*;.*$/\1;/
# append pattern to hold space, then swap
H;x
:finish
# remove \n
s/\n/ /g
# replace multi spaces with one ...
s/ {2,}/ /g
p
|