1 | #
|
---|
2 | # Strip stuff lines and spaces we don't care about.
|
---|
3 | #
|
---|
4 | / %line /d
|
---|
5 | /\[section /d
|
---|
6 | /\[bits /d
|
---|
7 | /\[absolute /d
|
---|
8 | / times /d
|
---|
9 | s/ *[0-9]* //
|
---|
10 | /^ *$/d
|
---|
11 | s/ *$//g
|
---|
12 | s/^ *//g
|
---|
13 | /^\.text$/d
|
---|
14 | /^\.data$/d
|
---|
15 | /^\.bss$/d
|
---|
16 |
|
---|
17 | #
|
---|
18 | # Figure which type of line this is and process it accordingly.
|
---|
19 | #
|
---|
20 | /^[A-Za-z][A-Za-z0-9_]*:/b struct
|
---|
21 | /<gap>/b member
|
---|
22 | b error
|
---|
23 |
|
---|
24 |
|
---|
25 | #
|
---|
26 | # Struct start / end.
|
---|
27 | #
|
---|
28 | :struct
|
---|
29 | s/:$//
|
---|
30 | h
|
---|
31 | s/^/global /
|
---|
32 | s/$/ ; struct/
|
---|
33 | b end
|
---|
34 |
|
---|
35 |
|
---|
36 | #
|
---|
37 | # Struct member
|
---|
38 | # Note: the 't' command doesn't seem to be working right with 's'.
|
---|
39 | #
|
---|
40 | :member
|
---|
41 | s/[0-9a-fA-Z]* *//
|
---|
42 | s/<gap> *//
|
---|
43 | /^\.[a-zA-Z0-9_.]*[:]* .*$/!t error
|
---|
44 | s/\(\.[a-zA-Z0-9_]*\)[:]* .*$/\1 /
|
---|
45 | G
|
---|
46 | s/^\([^ ]*\) \(.*\)$/global \2\1 ; member/
|
---|
47 | s/\n//m
|
---|
48 |
|
---|
49 | b end
|
---|
50 |
|
---|
51 | :error
|
---|
52 | s/^/\nSed script logic error!\nBuffer: /
|
---|
53 | s/$/\nHold: /
|
---|
54 | G
|
---|
55 | q 1
|
---|
56 | b end
|
---|
57 |
|
---|
58 |
|
---|
59 | :end
|
---|
60 |
|
---|