7 def process_file(fname
):
10 with
open(fname
) as f
:
12 if not l
.startswith("; Entry point: "):
15 head
, func_name
= l
.rsplit(None, 1)
18 print("Processing:", fname
)
20 os
.rename(fname
, fname
+ ".bak")
22 with
open(fname
+ ".bak") as f
, open(fname
, "w") as f_out
:
25 # Don't write this line
28 addr
, rest
= l
.split(None, 1)
29 f_out
.write("%s.0 %s:\n" % (addr
, func_name
))
30 f_out
.write("%s.0 goto %s.0\n" % (addr
, func_name
))
33 addr
, label
= l
.split(None, 1)
35 if label
[-1] == ":" and not label
.startswith("loc_"):
36 this_name
= label
[:-1]
37 if func_name
== this_name
:
38 l
= l
.replace(func_name
, func_name
+ ".0")
42 if __name__
== "__main__":
44 if os
.path
.isdir(sys
.argv
[1]):
45 for full_name
in glob
.glob(sys
.argv
[1] + "/*"):
46 if full_name
.endswith(".lst") and os
.path
.isfile(full_name
):
47 process_file(full_name
)
49 process_file(sys
.argv
[1])