|
Last change
on this file since b28a12e was 6262b5c, checked in by Thomas Lopatic <thomas@…>, 8 years ago |
|
Added include files for global functions and variables.
|
-
Property mode
set to
100755
|
|
File size:
971 bytes
|
| Line | |
|---|
| 1 | #!/usr/bin/env python3
|
|---|
| 2 |
|
|---|
| 3 | from sys import stdout
|
|---|
| 4 |
|
|---|
| 5 | with open("misc/c-files.txt", "r") as f:
|
|---|
| 6 | for path in f:
|
|---|
| 7 | path = path.rstrip()
|
|---|
| 8 |
|
|---|
| 9 | if path == "ram/wdfield.c": # breaks pycparser
|
|---|
| 10 | continue
|
|---|
| 11 |
|
|---|
| 12 | if path[-2:] != ".c":
|
|---|
| 13 | continue
|
|---|
| 14 |
|
|---|
| 15 | stdout.write("fixing {} \r".format(path))
|
|---|
| 16 | stdout.flush()
|
|---|
| 17 |
|
|---|
| 18 | with open(path, "r") as f:
|
|---|
| 19 | lines = f.read().split("\n")
|
|---|
| 20 |
|
|---|
| 21 | beg = None
|
|---|
| 22 | end = None
|
|---|
| 23 | idx = 0
|
|---|
| 24 |
|
|---|
| 25 | for line in lines:
|
|---|
| 26 | if len(line) >= 8 and line[:8] == "#include":
|
|---|
| 27 | if beg is None:
|
|---|
| 28 | beg = idx
|
|---|
| 29 |
|
|---|
| 30 | end = idx
|
|---|
| 31 |
|
|---|
| 32 | elif len(line) != 0 and beg is not None:
|
|---|
| 33 | break
|
|---|
| 34 |
|
|---|
| 35 | idx += 1
|
|---|
| 36 |
|
|---|
| 37 | if beg is not None:
|
|---|
| 38 | out = lines[0 : beg] + ["#include \"all.h\""] + lines[end + 1:] + [""]
|
|---|
| 39 |
|
|---|
| 40 | with open(path, "w") as f:
|
|---|
| 41 | f.write("\n".join(out))
|
|---|
| 42 |
|
|---|
| 43 | print("")
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.