forked from OSchip/llvm-project
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
This commit is contained in:
parent
837a1b84ce
commit
342b1b2e9b
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue