[llvm-commits] Console input should be opened in binary mode on Windows (Python setting)

NAKAMURA Takumi geek4civic at gmail.com
Mon Feb 28 01:59:00 PST 2011


Danil,

It is good, as long as the scripts would be used only to tests, thank you.

FYI I have another patch for this issue.
But anyway, I have not met this without msys bash. I don't know why.

...Takumi
-------------- next part --------------
commit 9101791704dd602e6999bb5f126ed61fa8c2bf26
Author: NAKAMURA Takumi <geek4civic at gmail.com>
Date:   Mon Nov 1 14:47:16 2010 +0900

    test/Scripts/coff-dump.py, elf-dump, macho-dump: Set setmode(O_BINARY) for stdin.

diff --git a/test/Scripts/coff-dump.py b/test/Scripts/coff-dump.py
index 36ec539..80cef87 100755
--- a/test/Scripts/coff-dump.py
+++ b/test/Scripts/coff-dump.py
@@ -579,6 +579,9 @@ def handle_element(entry):
 
 if len(sys.argv) <= 1 or sys.argv[1] == '-':
   import StringIO
+  if sys.platform == "win32":
+    import os, msvcrt
+    msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
   Input = StringIO.StringIO(sys.stdin.read())
 else:
   Input = open (sys.argv[1], "rb")
diff --git a/test/Scripts/elf-dump b/test/Scripts/elf-dump
index 76cdbf9..18f030c 100755
--- a/test/Scripts/elf-dump
+++ b/test/Scripts/elf-dump
@@ -226,6 +226,9 @@ if __name__ == "__main__":
 
     if not args:
         args.append('-')
+        if sys.platform == "win32":
+          import os, msvcrt
+          msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
 
     for arg in args:
         dumpELF(arg, opts)
diff --git a/test/Scripts/macho-dumpx b/test/Scripts/macho-dumpx
index 71e06d8..13053da 100755
--- a/test/Scripts/macho-dumpx
+++ b/test/Scripts/macho-dumpx
@@ -286,6 +286,9 @@ def main():
 
     if not args:
        args.append('-')
+       if sys.platform == "win32":
+          import os, msvcrt
+          msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
 
     for arg in args:
        dumpmacho(arg, opts)


More information about the llvm-commits mailing list