diff options
author | Pavel Labath <pavel@labath.sk> | 2019-10-10 12:40:27 +0000 |
---|---|---|
committer | Pavel Labath <pavel@labath.sk> | 2019-10-10 12:40:27 +0000 |
commit | 342b1b2e9b376835f17630d9697be4b78a019389 (patch) | |
tree | 5fd0e96f1940321128f925cf1961128e0a6b2c9a /lldb/source/Host/common/File.cpp | |
parent | 837a1b84ced64b3cf3dfdedb98fdcc187582892d (diff) | |
download | bcm5719-llvm-342b1b2e9b376835f17630d9697be4b78a019389.tar.gz bcm5719-llvm-342b1b2e9b376835f17630d9697be4b78a019389.zip |
File: Handle more cases in GetOptionsFromMode
The "b" (binary) flag is meaningless most of the time, but the relevant
standars allow it. The standards permit one to spell it both as "r+b"
and "rb+", so handle both cases.
This fixes TestFileHandle.test_binary_inout with python2.
llvm-svn: 374331
Diffstat (limited to 'lldb/source/Host/common/File.cpp')
-rw-r--r-- | lldb/source/Host/common/File.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lldb/source/Host/common/File.cpp b/lldb/source/Host/common/File.cpp index bd4cfcdb334..6498ec5b57e 100644 --- a/lldb/source/Host/common/File.cpp +++ b/lldb/source/Host/common/File.cpp @@ -70,15 +70,17 @@ static const char *GetStreamOpenModeFromOptions(uint32_t options) { uint32_t File::GetOptionsFromMode(llvm::StringRef mode) { return llvm::StringSwitch<uint32_t>(mode) - .Case("r", File::eOpenOptionRead) - .Case("w", File::eOpenOptionWrite) - .Case("a", File::eOpenOptionWrite | File::eOpenOptionAppend | - File::eOpenOptionCanCreate) - .Case("r+", File::eOpenOptionRead | File::eOpenOptionWrite) - .Case("w+", File::eOpenOptionRead | File::eOpenOptionWrite | - File::eOpenOptionCanCreate | File::eOpenOptionTruncate) - .Case("a+", File::eOpenOptionRead | File::eOpenOptionWrite | - File::eOpenOptionAppend | File::eOpenOptionCanCreate) + .Cases("r", "rb", eOpenOptionRead) + .Cases("w", "wb", eOpenOptionWrite) + .Cases("a", "ab", + eOpenOptionWrite | eOpenOptionAppend | eOpenOptionCanCreate) + .Cases("r+", "rb+", "r+b", eOpenOptionRead | eOpenOptionWrite) + .Cases("w+", "wb+", "w+b", + eOpenOptionRead | eOpenOptionWrite | eOpenOptionCanCreate | + eOpenOptionTruncate) + .Cases("a+", "ab+", "a+b", + eOpenOptionRead | eOpenOptionWrite | eOpenOptionAppend | + eOpenOptionCanCreate) .Default(0); } |