summaryrefslogtreecommitdiffstats
path: root/tools/sed-enums
blob: ffc193b7439e1d3ce2d18960161184c314d33369 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
s/^\s*(typedef)?\s+(enum(\s+\w+)?).*$/typedef \2 { /
T;h
:attrs;n
s/^\s*([A-Z0-9_]+)(\s*=\s*-?[0-9]+)?.*$/\1\2, /
T next;H;b attrs
:next
/^\s*\}/ ! b attrs
s/^\s*}\s*(\w+).*$/ } \1;/
t finish
:close
s/^\s*typedef\s+enum\s+\w+\s+(\w+)\s*;/ } \1/
t finish;n;b close
:finish
H;x
s/\n//g
s/ {2,}/ /g
s/, }/ }/p