From 59f4c9985e64a728aa6dbdb48d458ad6fadd5fbf Mon Sep 17 00:00:00 2001 From: Jean-Luc Duprat Date: Fri, 6 Jan 2012 16:56:09 -0800 Subject: [PATCH] Python files compatible with python 3 --- bitcode2cpp.py | 15 +++++++++------ stdlib2cpp.py | 11 +++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/bitcode2cpp.py b/bitcode2cpp.py index 8c09b216..e7c8eb77 100755 --- a/bitcode2cpp.py +++ b/bitcode2cpp.py @@ -26,17 +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 >> sys.stderr, "Couldn't open " + src + print("Couldn't open " + src, file=sys.stderr) sys.exit(1) -print "unsigned char builtins_bitcode_" + target + "[] = {" +print("unsigned char builtins_bitcode_" + target + "[] = {") +num = 0 for line in as_out.stdout.readlines(): length = length + len(line) for c in line: - print ord(c) - print ", " -print " 0 };\n\n" -print "int builtins_bitcode_" + target + "_length = " + str(length) + ";\n" + num+=1 + print("0x%0.2X, " % c, end="") + if num%16 == 0: + print() +print(" 0 };\n\n") +print("int builtins_bitcode_" + target + "_length = " + str(length) + ";\n") as_out.wait() diff --git a/stdlib2cpp.py b/stdlib2cpp.py index 6fa5fc2e..5e95c580 100755 --- a/stdlib2cpp.py +++ b/stdlib2cpp.py @@ -4,11 +4,14 @@ import sys t=str(sys.argv[1]) -print "char stdlib_" + t + "_code[] = { " +print("char stdlib_" + t + "_code[] = { ") +num = 0 for line in sys.stdin: for c in line: - print ord(c) - print ", " + num+=1 + print("0x%0.2X, " % ord(c), end="") + if num%16 == 0: + print() -print "0 };" +print("0 };")