summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2023-07-25 16:25:28 -0700
committerMatthew Sotoudeh <matthew@masot.net>2023-07-25 16:25:28 -0700
commit36fc249a02eb0ef32d3bc1d4e596683b64b1eb5f (patch)
tree7c3351c0ffc8bf4c4042bf9a74faa342c40aaaba
parentf2dd802a7a375217fa0a578752966465cf2c17bc (diff)
fix some dietcc bugs
-rwxr-xr-xscripts/dietcc17
1 files changed, 10 insertions, 7 deletions
diff --git a/scripts/dietcc b/scripts/dietcc
index 8898df2..110a647 100755
--- a/scripts/dietcc
+++ b/scripts/dietcc
@@ -4,6 +4,9 @@ import sys
import re
import tempfile
import os
+import shlex
+
+CC = "gcc"
if sys.argv[1:] == ["--version"]:
print("DIETC")
@@ -12,7 +15,7 @@ if sys.argv[1:] == ["--version"]:
# Have to do this because ./configure seems to do some nasty stuff
# https://lists.gnu.org/archive/html/bug-make/2022-11/msg00041.html
if "-E" in sys.argv[1:]:
- os.system(f"gcc {' '.join(sys.argv[1:])}")
+ os.system(f"{CC} {' '.join(map(shlex.quote, sys.argv[1:]))}")
sys.exit(0)
# https://stackoverflow.com/questions/595305
@@ -33,7 +36,7 @@ def preprocess_pass(c, meta):
t_file.flush()
dirname = os.path.dirname(os.path.realpath(meta["c_path"]))
return check_result(
- subprocess.run(f"gcc -I{dirname} -E {meta['argstr']} {t_file.name}",
+ subprocess.run(f"{CC} -I{dirname} -E {meta['argstr']} {t_file.name}",
shell=True, capture_output=True))
def strip_after_preprocess_pass(c, meta):
@@ -130,7 +133,7 @@ PASSES = [preprocess_pass,
final_cleanup_pass]
def main():
- args = sys.argv[1:]
+ args = list(map(shlex.quote, sys.argv[1:]))
args.insert(0, f"-I{dietc_dir}/scripts/stdincludes")
# first, parse out any DietC passes
dietc_passes = []
@@ -146,9 +149,9 @@ def main():
for i, c_file in enumerate(c_files):
subargs = [arg for arg in args if not arg.endswith(".c")]
if "-o" in subargs:
- i = subargs.index("-o")
- subargs.pop(i)
- subargs.pop(i)
+ i_ = subargs.index("-o")
+ subargs.pop(i_)
+ subargs.pop(i_)
argstr = " ".join(subargs)
last = open(c_file, "rb").read()
@@ -165,7 +168,7 @@ def main():
if c_files and "-o" not in args:
if "-c" in args:
args += ["-o", c_files[0].replace(".c", ".o")]
- gcc = subprocess.run(f"gcc {' '.join(args)} -Wno-int-to-pointer-cast -Wno-builtin-declaration-mismatch", shell=True)
+ gcc = subprocess.run(f"{CC} {' '.join(args)} -Wno-int-to-pointer-cast -Wno-builtin-declaration-mismatch", shell=True)
check_result(gcc)
main()
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback