From 5d67252ed01a3e3dbd9595e9c2253ea723013fa1 Mon Sep 17 00:00:00 2001 From: Jean-Luc Duprat Date: Mon, 9 Jan 2012 13:56:05 -0800 Subject: [PATCH] Python scripts now compatible with both 2.x and 3.x releases of python --- bitcode2cpp.py | 12 ++++++------ stdlib2cpp.py | 9 ++++----- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/bitcode2cpp.py b/bitcode2cpp.py index e7c8eb77..9e16ecea 100755 --- a/bitcode2cpp.py +++ b/bitcode2cpp.py @@ -26,20 +26,20 @@ if platform.system() == 'Windows' or string.find(platform.system(), "CYGWIN_NT") try: as_out=subprocess.Popen([llvm_as, "-", "-o", "-"], stdout=subprocess.PIPE) except IOError: - print("Couldn't open " + src, file=sys.stderr) + sys.stderr.write("Couldn't open " + src) sys.exit(1) -print("unsigned char builtins_bitcode_" + target + "[] = {") +sys.stdout.write("unsigned char builtins_bitcode_" + target + "[] = {\n") num = 0 for line in as_out.stdout.readlines(): length = length + len(line) for c in line: num+=1 - print("0x%0.2X, " % c, end="") + sys.stdout.write("0x%0.2X, " % ord(c)) if num%16 == 0: - print() -print(" 0 };\n\n") -print("int builtins_bitcode_" + target + "_length = " + str(length) + ";\n") + sys.stdout.write("\n"); +sys.stdout.write(" 0 };\n\n") +sys.stdout.write("int builtins_bitcode_" + target + "_length = " + str(length) + ";\n") as_out.wait() diff --git a/stdlib2cpp.py b/stdlib2cpp.py index 5e95c580..1d083d80 100755 --- a/stdlib2cpp.py +++ b/stdlib2cpp.py @@ -4,14 +4,13 @@ import sys t=str(sys.argv[1]) -print("char stdlib_" + t + "_code[] = { ") +sys.stdout.write("char stdlib_" + t + "_code[] = {\n") num = 0 for line in sys.stdin: for c in line: num+=1 - print("0x%0.2X, " % ord(c), end="") + sys.stdout.write("0x%0.2X, " % ord(c)) if num%16 == 0: - print() - -print("0 };") + sys.stdout.write("\n") +sys.stdout.write("0 };\n")